Convert Python List to Column in CSV

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

I have a list of values (v1, v2, v3) and I want to write these to a column called VALUES in a csv. I'm using csvreader and csvwriter to get as far as I have. I've only figured out how to write them to rows using csvwriter.writerow.

回答1:

It sounds like you have tried:

values = [1, 2, 3, 4, 5] thecsv = csv.writer(open("your.csv", 'wb')) thecsv.writerow(values) 

Perhaps you should try:

values = [1, 2, 3, 4, 5] thecsv = csv.writer(open("your.csv", 'wb')) for value in values:     thecsv.writerow(value) 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!