I am trying to write the elements of a list (each time I get from a for loop) as individual columns to a CSV file. But the elements are adding as an individual rows, but not columns.
I am new to python. What needs to be changed in my code? Please tell me
import csv
row=['ABC','XYZ','','','ABCD',''] #my list looks like this every time
with open('some.csv', 'w') as writeFile:
writer = csv.writer(writeFile, delimiter=',', quotechar='"')
for item in row:
writer.writerow([item])
But I am getting the output as below:
ABC
XYZ
ABCD
My expected output is a below:
ABC XYZ ABCD
writer.writerows[row]iterationhere. Use withoutfor