Description | This article describes how to convert JSON files to Excel. |
Scope | FortiEDR. |
Solution |
This python script will convert JSON to CSV: https://fortiedr.sharefile.com/d-s454b54b46e844d0a9d0630c6d1e274cc Save the Postman response file as response.json to a folder and put the jsontocsv.py script in the same folder then run it. python3 jsontocsv.py Import jsonimport csvwith open('response.json') as json_file:
jsondata = json.load(json_file) data_file = open('jsonoutput.csv', 'w', newline='') csv_writer = csv.writer(data_file) count = 0for data in jsondata: if count == 0: header = data.keys() csv_writer.writerow(header) count += 1 csv_writer.writerow(data.values()) data_file.close() |
Labels: