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
Great, Thank you. I also found out about csv2rec. I've been missing these two a lot. Le 03/09/2010 15:35, Pierre GM a écrit :
On Sep 3, 2010, at 3:32 PM, Guillaume Chérel wrote:
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. matplotlib.mlab.rec2csv
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
2010/9/3 Guillaume Chérel <guillaume.c.cherel@gmail.com>:
Great, Thank you. I also found out about csv2rec. I've been missing these two a lot.
Some other handy rec functions in mlab http://matplotlib.sourceforge.net/examples/misc/rec_groupby_demo.html http://matplotlib.sourceforge.net/examples/misc/rec_join_demo.html JDH
On Fri, Sep 3, 2010 at 8:35 AM, Pierre GM <pgmdevlist@gmail.com> wrote:
On Sep 3, 2010, at 3:32 PM, Guillaume Chérel wrote:
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.
matplotlib.mlab.rec2csv _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Why is this function in matplotlib? Wouldn't it be more useful in numpy? Ben Root
On Fri, Sep 3, 2010 at 8:50 AM, Benjamin Root <ben.root@ou.edu> wrote:
Why is this function in matplotlib? Wouldn't it be more useful in numpy?
I tend to add stuff I write to matplotlib. mlab was initially a repository of matlab-like functions that were not available in numpy (load, save, linspace, psd, cohere, polyfit, polyval, prctile, ...). I've always encouraged numpy developers to harvest what they want and move them into numpy, and many of these functions have been moved. Once they make it into stable numpy, we deprecate them and eventually remove them from mlab. Many of the rec functions have been ported to numpy in numpy.lib.recfunctions. There are some differences, particularly in the csv2rec (mpl handles date parsing) and I rely heavily on all these functions, so I have not ported all my code to use numpy yet. We should start the process of deprecating the ones that have been ported and have API and functional compatibility. JDH
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
participants (5)
-
Benjamin Root
-
Erin Sheldon
-
Guillaume Chérel
-
John Hunter
-
Pierre GM