Converting JSON files to .csv -
i've found data downloading json file (i think! - i'm newb!). file contains data on 600 football players.
in past, have downloaded json file , used code:
import csv import json json_data = open("file.json") data = json.load(json_data) f = csv.writer(open("fix_hists.csv","wb+")) arr = [] in data: fh = data[i]["fixture_history"] array = fh["all"] j in array: try: j.insert(0,str(data[i]["first_name"])) except: j.insert(0,'error') try: j.insert(1,data[i]["web_name"]) except: j.insert(1,'error') try: f.writerow(j) except: f.writerow(['error','error']) json_data.close()
sadly, when in command prompt, following error:
traceback (most recent call last): file"fix_hist.py", line 12 (module) fh = data[i]["fixture_history"] typeerror: list indices must integers, not str
can fixed or there way can grab of data , convert .csv? 'fixture history'? , 'first'name', 'type_name' etc.
thanks in advance :)
try tool: http://www.convertcsv.com/json-to-csv.htm
you need configure few things, should easy enough.
Comments
Post a Comment