import pandas as pd
import csv
csv_columns = ['quesion,,options,answer,src']
data = open("aug6m.csv")
readBytes = data.read()
data1 = eval(readBytes)
questions = []
csv_file = "Names.csv"
print("vgfhgf", data1[0])
for item in data1:
try:
with open(csv_file, 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
writer.writeheader()
for data in item:
writer.writerow(data)
except IOError:
print("I/O error")
What I have tried:
this is my python code and aug6m.csv file have dictionary data like
{'question': 'A petition has been launched requesting that which game be made into an official Olympic sport?', 'answers': ['Yu-Gi-Oh!', 'Dungeons and Dragons', 'Chess', Texas Hold'em poker], 'answerIndex': [0], 'image_url': 'https://cdn.riddle.com/embeds/v2/images/q_80,c_fill,w_960,h_540/892/892e4e3759aa101047700d12a383bde3.jpg'}{....}{....}
etc.. but i want to store like each key value separate
column for example question,option,answer,src