Reputation: 4636
This must be very simple.
I'm trying to put a header in my csv file, the string 'Date,Value', as you can see below.
with open('ticker.csv', 'wb') as f:
writer = csv.writer(f)
writer.writerows('Date,Value')
writer.writerows(izip(dates, values))
f.close()
However I'm getting a multirowed string, like this:
D
a
t
e
","
V
a
l
u
e
2002-03,12.9
2002-04,12.5
2002-05,11.9
How can I fix that?
Upvotes: 0
Views: 505
Reputation: 829
Here is the solution
writer = csv.writer(f)
writer.writerow(['Date','Value'])
writer.writerows(izip(dates, values))
f.close()
Upvotes: 1