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
A:
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)
Robert Kluin
2010-10-11 01:25:04
I tried that. My values have multiple characters (v1, v2, v3) and when I use the method you suggest, row 1 column 1 gets "v", row 1 column 2 gets "1", row 2 column 1 gets "v", row 2 column 2 gets "2" etc.
Billy
2010-10-11 01:31:02
Try changing `thecsv.writerow(value)` to `thecsv.writerow([value])`.
Robert Kluin
2010-10-11 01:34:27
That did it! You're a genius. Thank you!
Billy
2010-10-12 21:53:02