table::jsonl
JSON lines: one JSON object per line, a row each. Columns are the
keys in order of first appearance (a key a row leaves out is null);
integers that fit become i64, other numbers f64, nested arrays
and objects their JSON text.
Functions
read_jsonl_strSource
pub fn read_jsonl_str(s: str) throws (TableError) -> Table A table from JSON lines text; blank lines are skipped.
nabi
let t = try table::read_jsonl_str("{\"a\": 1, \"b\": \"x\"}\n{\"a\": 2.5}\n") catch _ { table::Table::new() };
assert(t.names() == ["a", "b"]);
assert(t.column_at(0).dtype() == table::DType::F64);
assert(t.row(1).get("b") == table::Value::Null);
read_jsonlSource
pub fn read_jsonl(path: str) throws (TableError) -> Table The JSON lines file at path as a table.
nabi
let t = try "events.jsonl" |> table::read_jsonl;
row_jsonSource
pub fn row_json(t: Table, i: usize) -> json::Value Row i of t as a JSON object (dates as ISO text, NaN and
infinities as null).
write_jsonl_strSource
pub fn write_jsonl_str(t: Table) -> str The table as JSON lines, one object per row, each line ended by \n.
nabi
let t = table::table!{ "a": [1, none], "b": ["x", "y"] };
assert(table::write_jsonl_str(t) == "{\"a\":1,\"b\":\"x\"}\n{\"a\":null,\"b\":\"y\"}\n");
write_jsonlSource
pub fn write_jsonl(t: Table, path: str) throws (TableError) Write the table as JSON lines to path.
nabi
let t = table::table!{ "a": [1, none] };
try t |> table::write_jsonl("out.jsonl");