[SciPy-User] Padded data structure
Sun Feb 21 02:02:09 CST 2010
Miguel de Val Borro wrote:
> On Sat, Feb 20, 2010 at 10:55:59PM -0800, Christopher Barker wrote:
>>> I would like to read padded output files from C structures that look
>>> like this file: http://spec.jpl.nasa.gov/ftp/pub/catalog/catdir.cat
>>> The second row is a 13 character string that contains whitespaces. I
>>> have looked at the align option in dtype passed as a parameter to
>>> loadtxt but could not make it work.
>> Since there is whitespace between all those columns, I don't think you
>> need align. I suspect that a dtype something like:
>> ('i4', 'S13', 'i4', 'f8', 'f8','f8','f8','f8','f8','f8', 'i2')
> The problem is that the S13 string contains whitespaces, which is also
> the separator between columns. Using this dtype I get the error:
> ValueError: invalid literal for float(): v2,2v2,v
Any chance you can upgrade your numpy version to the current trunk?
Somewhere between version 1.3.0 and the current trunk, the 'delimiter'
argument of genfromtxt() was enhanced to accept a list of field widths.
The attached script shows how it can be used to read the file "catdir.dat".
> SciPy-User mailing list
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the SciPy-User