ijson example : read large json file too big to fit into memory

Working with large JSON files and need to read them without loading into memory? ijson to the rescue!

ijson is essentially a generator that can read JSON files :D

from pprint import pprint
import ijson as ijson

with open("path/to/file.json", 'rb') as json_file:
    for item in ijson.items(json_file, "item"):
        pprint(item['one'], width=1000)
        pprint(item['two'], width=1000)
SNAPPED!

SNAPPED!

Comments

Popular posts from this blog

Append to a json file python

Setup Mailhog mail server on Ubuntu