Nov-14-2023, 10:06 PM
I don't know how to use pandas very well.
Hard to know what starts where and what ends where in the json.
I thinks this gets what you want.
Look carefully at the output of
Hard to know what starts where and what ends where in the json.
I thinks this gets what you want.
Look carefully at the output of
for item in json_data.items(): print(json.dumps(item, indent = 4, sort_keys=True))Sub keys are further right than leading keys. Look for lists as well!
import json import csv myfile = '/home/pedro/myPython/json/csv/outputfile.csv' with open(myfile) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') data = [] for row in csv_reader: data.append(row) for d in data: print(d, len(d) # get the last element of data[1] this is the json json_data = json.loads(data[1][16]) for key in json_data.keys(): print(json.dumps(key, indent = 4, sort_keys=True)) for item in json_data.items(): print(json.dumps(item, indent = 4, sort_keys=True)) print(json_data["hits"]['hits'][0]['_source']['idAffaire']) print(json_data["hits"]['hits'][0]['_source']['demande']['prestation']['code'])