Excerpts from Guillaume Chérel's message of Fri Sep 03 09:32:02 -0400 2010: > Hello, > > I'd like to know if there is a convenient routine to write recarrays > into cvs files, with the first line of the file being the name of the > fields. > > Thanks, > Guillaume
Yes, you can do this with the recfile package: http://pypi.python.org/pypi/recfile/0.40 http://code.google.com/p/recfile/ import numpy import recfile rec = numpy.zeros(3, dtype=[('x','f4'),('y','i8')]) rec['x'] = [0,1,2] rec['y'] = [0,1,2] recf = recfile.Open('filename.csv', 'w', delim=',') names = rec.dtype.names header = ','.join(names) recf.fobj.write(header+'\n') recf.write(rec) recf.close() Erin Scott Sheldon Brookhaven National Laboratory _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
