I want to insert two columns in a new csv file. Question1 data should be in first column and Question2 data should be in second column
below given code gives me this output:
['question1']
['a','b','c','d']
['e','f','g']
['h','i','j','k','l']
['question2']
['a','b','c','d','x','y']
['e','f','g','m','n','o','p','q']
['h','i','j','k','l','r','s',]
Here is my code:
col1=question1.split("\n")
col2=question2.split("\n")
with open("outputFile.csv" , mode="wt", encoding='UTF-8') as out_file:
w=csv.writer(out_file)
for row in col1:
myColumns = row.split("\n")
print(myColumns)
w.writerow(myColumns)
for row in col2:
myColumns = row.split("\n")
print(myColumns)
w.writerow(myColumns)
the output should be like this: question1 should be in first column of csv and question 2 should be in second column of csv file
['question1'] ['question2']
['a','b','c','d'] ['a','b','c','d','x','y']
['e','f','g'] ['e','f','g','m','n','o','p','q']
['h','i','j','k','l'] ['h','i','j','k','l','r','s',]
Please help me how can I solve the problem..
question1 = [['What', 'step', 'step', 'guide', 'invest', 'share', 'market', 'india'],['What', 'story', 'Kohinoor', 'KohiNoor', 'Diamond'] ...]Do you need the entire list on one line? Or each list element on one line?