Search code examples
pythonjsonjsonlines

PYTHON: reading .jl file using jsonlines is resulting in line of json. I need all the json lines


I am trying to read the file from the path and add to the dictionary, however, i end up with first json-line and there are about 230MB of data.

I have folder like here

# folder path 
folder = os.path.expanduser("~/topic_2022-05-30T23-15-20.jl")

#Initialise the dictionary    
items = {}
with open(folder, 'rb') as f:
for item in json_lines.reader(f):
        
    # adding next item to items
    items.update(item)

Solution

  • import json
    file = open(folder)
    items = {}
    data = json.load(file)
    for k, v in data.items():
        items.update(k:v) 
     
    file.close()
    

    itmes = data could also work.