Writing csv header removes data from numpy array written below

Posted by user338095 on Stack Overflow See other posts from Stack Overflow or by user338095
Published on 2010-05-11T09:31:26Z Indexed on 2010/05/11 9:34 UTC
Read the original article Hit count: 221

Filed under:
|
|

I'm trying to export data to a csv file. It should contain a header (from datastack) and restacked arrays with my data (from datastack). One line in datastack has the same length as dataset. The code below works but it removes parts of the first line from datastack. Any ideas why that could be?

s = ','.join(itertools.chain(dataset)) + '\n'
newfile = 'export.csv'
f = open(newfile,'w')
f.write(s)
numpy.savetxt(newfile, (numpy.transpose(datastack)), delimiter=', ')
f.close()

© Stack Overflow or respective owner

Related posts about python

Related posts about numpy