python - How to write list to csv, with each item on a new row -


i having trouble writing list of items csv file, each item being on new row. here have, want, except putting each letter on new row...

import csv  data = ['first item', 'second item', 'third item']     open('output.csv', 'w', newline='') csvfile:     writer = csv.writer(csvfile)     in data:         writer.writerows(i) 

use nested list: writer.writerows([[i]]). explanation writing data python list csv row-wise:

.writerow takes iterable , uses each element of iterable each column. if use list 1 element placed in single column.

so, need single column, ...


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -