JsonReadOptions(layout=JsonLayout.RECORDS, column_names=ColumnNames.CLEANED)
Source¶
Settings of a JSON file read by Table.from_json.
JSON files are always read in UTF-8.
Added in version 0.1.0
Parameters:
-
layout(JsonLayout, default:JsonLayout.RECORDS)The layout of the rows, one list of objects by default.
-
column_names(ColumnNames, default:ColumnNames.CLEANED)Whether the column names are cleaned,
ColumnNames.CLEANEDby default: the spaces, tabs and line breaks at the start and the end of each name are removed.ColumnNames.KEPTkeeps the names as written.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
Examples:
import tempfile
from pathlib import Path
import numdaplot as ndp
path = Path(tempfile.mkdtemp()) / "sales.jsonl"
_ = path.write_text('{"city": "Paris", "count": 2}\n{"city": "Lyon", "count": 5}\n')
ndp.Table.from_json(path, ndp.JsonReadOptions(layout=ndp.JsonLayout.LINES))
# city count
# TEXT INT64
# 0 Paris 2
# 1 Lyon 5