I'm trying to export a a recarray to csv file with rec2csv so I can retrieve it later with csv2rec. The problem is that the rec2csv is exporting with a blank line between each rows, so csv2rec cannot read it later. How can I fix this problem with the function rec2csv?
Basically, what I'm trying to do is this:
ticker = 'GOOG'
startdate = datetime.date(2011,1,1)
enddate = datetime.date.today()
fh = finance.fetch_historical_yahoo(ticker, startdate, enddate)
r = mlab.csv2rec(fh); fh.close()
r.sort()
After some calculations,
fl = open(r'J:\export.csv', 'w')
mlab.rec2csv(r,fl); fl.close()
Then I want to be able to import this file again with:
ff = mlab.csv2rec('J:\\export.csv')
This give an error message (IndexError: list index out of range) because there are blank lines between rows.