So i am trying to import json data from file and want to export in CSV file. Only few tags like "authors" and "title" work fine with this code but when i try that for "abstract" it split every word of abstract in new column of csv. Before I try split() it was doing the same for every character
here is my code
import json
import csv
filename="abc.json"
csv_file= open('my.csv', 'w',encoding="utf-8")
csvwriter = csv.writer(csv_file)
with open(filename, 'r') as f:
for line in f:
data = json.loads(line)
if 'abstract' in data:
csvwriter.writerow(data['abstract'].split())
elif 'authors' in data:
csvwriter.writerow(data['authors'])
else:
f="my"
sample json file can be downloaded from here http://s000.tinyupload.com/?file_id=28925213311182593120