Click here to Skip to main content
15,507,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
import pandas as pd
import csv
csv_columns = ['quesion,,options,answer,src']

data = open("aug6m.csv")
readBytes =
data1 = eval(readBytes)
questions = []
csv_file = "Names.csv"
print("vgfhgf", data1[0])

for item in data1:

        with open(csv_file, 'w') as csvfile:
            writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
        for data in item:
    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': ',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
Updated 18-Aug-21 5:57am
Richard MacCutchan 18-Aug-21 11:26am    
That does not look very much like valid csv; more like JSON.
Maciej Los 19-Aug-21 3:12am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900