0

CSV writing in Python

I wanted to write somedata in csv, the code is as follows: import csv row = ['2', 'Marie', 'California'] file = open('D://file.csv','w') with file: writer = csv.writer(file) writer.writerows(row) file.close() # End of code The o/p I expected in file.csv is 2, Marie, California but instead, I m getting: 2 M,a,r,i,e C,a,l,i,f,o,r,n,i,a Can somebody help me?

23rd May 2018, 5:38 AM
suraj jadhav
suraj jadhav - avatar
1 Odpowiedź
+ 1
Thanks Jan, it worked.
23rd May 2018, 6:24 AM
suraj jadhav
suraj jadhav - avatar