stream_in: Stream in & flatten an ndjson file into a 'data.table'

View source: R/ndjson.R

stream_inR Documentation

Stream in & flatten an ndjson file into a data.table

Description

Given a file of streaming JSON (ndjson) this function reads in the records and creates a flat data.table / tbl from it.

Usage

stream_in(path, cls = c("dt", "tbl"))

Arguments

path

path to file (supports "gz" files)

cls

the package uses data.table::rbindlist for speed but that's not always the best return type for everyone, so you have option of keeping it a data.table or converting it to a tbl

Value

data.table or tbl

References

http://ndjson.org/

Examples

f <- system.file("extdata", "test.json", package="ndjson")
nrow(stream_in(f))

gzf <- system.file("extdata", "testgz.json.gz", package="ndjson")
nrow(stream_in(gzf))

ndjson documentation built on Oct. 17, 2022, 9:06 a.m.

Related to stream_in in ndjson...