I have a json file with a size of 5 GB. I would like to load it and do some EDA on it in order to figure out where the relevant information is.
I tried:
import json
import pprint
json_fn = 'abc.ndjson'
data = json.load(open(json_fn, 'rb'))
pprint.pprint(data, depth=2)
but this just crashes with
Process finished with exit code 137 (interrupted by signal 9: SIGKILL)
I also tried:
import ijson
with open(json_fn) as f:
items = ijson.items(f, 'item', multiple_values=True) # "multiple values" needed as it crashes otherwise with a "trailing garbage parse error" (https://stackoverflow.com/questions/59346164/ijson-fails-with-trailing-garbage-parse-error)
print('Data loaded - no processing ...')
print("---items---")
print(items)
for item in items:
print("---item---")
print(item)
But this just returns:
Data loaded, now importing
---items---
<_yajl2.items object at 0x7f436de97440>
Process finished with exit code 0
The ndjson file contains valid ascii characters (as inspected with vi) but very long lines and is therefore not really comprehensible from a text editor.
The file starts like:
{"visitId":257057,"staticFeatures":[{"type":"CODES","value":"9910,51881,42833,486,4280,42731,2384,V5861,9847,3962,49320,3558,2720,4019,99092"},{"type":"visitID","value":"357057"},{"type":"VISITOR_ID","value":"68824"}, {"type":"ADMISSION_ID","value":"788457"},{"type":"AGE","value":"34"}, ...
What am I doing wrong and how can I process this file?