Search code examples
pythonimportjupyter-notebooklibrariesndjson

How do you import a ndjson file in jupyter notebook


I have tried the code below but it's not working

import json
with open("/Users/elton/20210228test2.ndjson") as f:
    test2data = ndjson.load(f)

Solution

  • This works for me. import ndjson instead of import json. See more here: https://pypi.org/project/ndjson/

    import ndjson
    
    # load from file-like objects
    with open('data.ndjson') as f:
        data = ndjson.load(f)