I am working with JSON files in python. I have keys in a list, for each key I retrieve a JSON record, which I store in a file. Each JSON record contains that key inside.
In a separate process, I need to read that JSON file and retrieve each record, get key and do something else.
The problem is I cannot read JSON lines from file I stored this way:
dataFile = open(output_file, "w")
for line in keys_list:
json_line = fetch_json_str(line)
data = simplejson.loads(json_line)
dataFile.write(simplejson.dumps(data, sort_keys = True))
It reads all into one line, and the length of returned list is 0, len(json_lines).
json_lines = [line.strip() for line in open(tmp_load_file)]
for line in json_lines
data = simplejson.loads(simplejson.dumps(line))
What do I do wrong? Is there any way to get back JSON lines without changing the way I stored them, because that will call for re-processing all the json files I stored this way.