Billy
Billy

Reputation: 43

Convert Python List to Column in CSV

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.

Upvotes: 4

Views: 6029

Answers (1)

Robert Kluin
Robert Kluin

Reputation: 8292

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)

Upvotes: 3

Related Questions