I have one ndJson file where I have to manipulate the data, I am just extracting the data in one variable in dictionary format and wanted to create new json file to store it, But I am unable to do so.
I have tried creating new file which can store the value which my dictionary variable holds.
Here is the code
with open("C:\\Users\\Lalith K\\Downloads\\ENUMtransactions.json") as f:
data = [json.loads(l) for l in f.readlines()]
for i in range(len(data)):
if i % 2 == 0:
newDataE = (data[i])
print(newDataE)
outfile = open('p.json', 'w')
print(newDataE, file=outfile)
My newDataE holds the output in dictionary format i.e. {'index': {'_index': 'packets-2022-09-28', '_type': 'pcap_file'}} during my each repetition this is the output with changed date. When I am trying to create new file it is only holding one value instead of all the values.
Please help me how to add all the values in new JSON file where each json is seprated with line break from another.
Image for purpose of output I want which I am getting on the console I want it in the JSONfile.