If reading as data.frame, each row of ndjson becomes a row in the data.frame. If reading as a list, then each row becomes an element in the list.

from_ndjson_file_as_df(
  filename,
  nread = -1,
  nskip = 0,
  nprobe = 100,
  opts = list(),
  ...
)

from_ndjson_file_as_list(filename, nread = -1, nskip = 0, opts = list(), ...)

Arguments

filename

text file or gzipped file

nread

number of records to read. Default: -1 (reads all rows)

nskip

number of records to skip before starting to read. Default: 0

nprobe

Number of lines to read to determine types for data.frame columns. Default: 100. Only valid for from_ndjson_file_as_df()

opts

Named list of options for parsing. Usually created by from_opts()

...

Other named options can be used to override any options in opts. The valid named options are identical to arguments to from_opts()

Value

data.frame

list

Details

If parsing ndjson to a data.frame it is usually better if the json objects are consistent from line-to-line. Type inference for the data.frame is done during initialisation by reading through nprobe lines. Warning: if there is a type-mismatch further into the file than it is probed, then you will get missing values in the data.frame.

No flattening of the namespace is done i.e. nested object remain nested.

See also

Examples

if (FALSE) {
from_ndjson_file_as_df("flights.ndjson", nskip = 1000, nread = 200)
from_ndjson_file_as_list("flights.ndjson", nskip = 1000, nread = 200)
}