I am having problems exporting certain items in a dictionary to CSV. I can export 'name' but not 'images' (the image URL).
This is an example of part of my dictionary:
new = [{ "name" : "peter", "picture" : "https://img.evbuc.com/https%3A%2F%2Fcdn.evbuc.com%2Fimages%2F33500665%2F25911657759%2F1%2Foriginal.jpg?h=200&w=450&rect=0%2C581%2C6000%2C3000&s=bfaa2901b8c906a66c51563d15c6df12"},
{"name" : "jim" , "picture" : "https://img.evbuc.com/https%3A%2F%2Fcdn.evbuc.com%2Fimages%2F32935536%2F10115879927%2F1%2Foriginal.jpg?h=200&w=450&rect=0%2C40%2C624%2C312&s=c67e995e83234ab460707ac21f3541f8"}]
EDIT (I made a mistake with the naming as was what pointed out. It seems to work now after updating it).
And this is the code I have written (which works for 'name' but not 'picture'):
import csv
test = []
for document in new:
event_obj = {}
# Get name
event_obj['name'] = document['name']
# Get images
event_obj['picture'] = document['picture']
test.append(event_obj)
# Create CSV file
with open('Eventbrite_events.csv', 'w', newline='') as csvfile:
fields = ['name', 'picture']
writer = csv.DictWriter(csvfile, fieldnames=fields)
writer.writeheader()
for x in test:
writer.writerow(x)
print(csvfile)