Apologies for the poorly worded title.
Basically, I have a csv file where rows look like this:
1234567, Install X Software on Y Machine, ServiceTicket,"{'id': 47, 'name': 'SERVICE BOARD', '_info': {'board_href': 'https://MY-URl'}}","{'id': 897, 'name': 'Completed', '_info': {'status_href': 'https://MY-URl'}}...
The first nested list's key name is 'board' and the second is 'status'. I am trying to format this such that the nested 'name' key is used in place of 'board' and 'status.' I would like it to be formatted like this:
1234567, Install X Software on Y Machine, ServiceTicket, SERVICE BOARD, Completed
I am completely lost on this. Any help would be greatly appreciated.
The following is my code for retrieving .json data from a get request and converting it to .csv:
data = requests.get(url=TICKET_URL, headers=HEADER_AUTH) ### Get data from
data = data.json()
count = 0;
csvData = open("test.csv", "w")
csvWriter = csv.writer(csvData)
with open("data.json", "w") as f:
for item in data:
if count == 0:
header = item.keys()
csvWriter.writerow(header)
count += 1
csvWriter.writerow(item.values())
f.write("%s\n" % item)
csvData.close()
f.close()