I have a JSON file which is 5 lines long. I want to write each line to a seperate file, i.e write line1
to file1
, line2
to file2
etc
Now, I am trying to write the file in a file, but data is in a line and disorder, and there is a weird 'u' before each key and value on the writing file.
import json
with open("test1.json") as f:
with open("1.json","w") as o:
lines = f.readline()
for line in lines:
y = json.loads(line)
print(y)
json.dump(y,o)