JSON File Parse Python -


[{"cat1":136803,"cat2":"1.4545","cat3":"0.0885","cat4":"112969"},  {"cat1":1564654,"cat2":"2.5448","cat3":"0.0568","cat4":"5468489"},  {"cat1":5484654,"cat2":"1.8948","cat3":"0.0478","cat4":"898489"}] 

i have json structure looks 1 above.

my code:

import json pprint import pprint  open('file/path') data_file:         data = json.load(data_file)  data["cat1"] 

give me error list indicies must integers not, str

how can parse return want, "cat1"?

my goal parse out want json file , write csv file.

your json structure list of dictionary. so, have write:

data[0]["cat1"] 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -