Closed ColinMaudry closed 3 years ago
Hi @ColinMaudry !
The init script is a bit simplistic (and maybe outdated), but it's possible to load this json file using the Python interface, as follows:
% cat > bla.json
{
"marches": [
{
"id": "1",
"name": "Colin"
},
{
"id": "2",
"name": "Anne Lise"
}
]
}
% python
Python 3.7.8 (default, Aug 24 2020, 11:26:01)
Type "help", "copyright", "credits" or "license" for more information.
>>> import dataflows as DF
>>> DF.Flow(DF.load('bla.json', property='marches'), DF.printer()).process()
bla:
# id name
(integer) (string)
--- ----------- ----------
1 1 Colin
2 2 Anne Lise
The key is to specify the exact property you'd like to extract from the json file using the property
argument to load
.
That works fine, thanks!
The property
argument isn't documented, right? https://github.com/datahq/dataflows/blob/master/PROCESSORS.md#load
Indeed, we use tabulator
as the file handing engine, and most of load
's arguments are passed as-is to tabulator.
So, instead of re-documenting we rely on tabulator
's documentation - e.g. property
is documented here: https://github.com/frictionlessdata/tabulator-py#json-read--write
Hello,
I'm trying to load and display a simple JSON file, but I fail to do so.
simple.json:
Command line:
The resulting simple_json.py:
Could you please provide a simple code snippet that shows how I can load and process a JSON file?
Thanks!