I am trying to parse a large (~ 100 MB) json file using the ijson package, which allows me to interact effectively with the file. However, after writing such code,
with open(filename, 'r') as f:
parser = ijson.parse(f)
for prefix, event, value in parser:
if prefix == "name":
print(value)
I found that the code parses only the first line, not the rest of the lines from the file !!
Here is what part of my json file looks like:
{"name":"accelerator_pedal_position","value":0,"timestamp":1364323939.012000}
{"name":"engine_speed","value":772,"timestamp":1364323939.027000}
{"name":"vehicle_speed","value":0,"timestamp":1364323939.029000}
{"name":"accelerator_pedal_position","value":0,"timestamp":1364323939.035000}
In my opinion, I think that ijsonparses only one json object.
Can anyone suggest how to get around this?
source
share