[AstroPy] reading fixed format tables

Derek Homeier derek at astro.physik.uni-goettingen.de
Mon Dec 5 17:33:53 EST 2011


On 05.12.2011, at 9:43PM, Matt Davis wrote:

> It looks like numpy.genfromtxt can also do this, see the last example: http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html
> 
Yes, using delimiter=[11,7,6,12,5…] will do this; you'd also have to calculate the 
widths from the Fortran specifiers and provide the necessary dtypes for int or string. 

There also has been a FortranFormat package around for a long time which still seems 
to be alive here
http://pypi.python.org/pypi/fortranformat

and directly understands the Fortran specifiers. Last time I've used it it was very slow, 
but that may have improved (if it is even the same package).

Cheers,
						Derek

> - Matt
> 
> On Dec 5, 2011, at 3:41 PM, Tom Aldcroft wrote:
> 
>> Asciitable of course :).   See the second example here:
>> 
>> http://cxc.harvard.edu/contrib/asciitable/fixed_width_gallery.html#fixedwidthnoheader
>> 
>> You'll have to calculate the column start and stop indexes.
>> 
>> - Tom
>> 
>> On Mon, Dec 5, 2011 at 3:36 PM, Wolfgang Kerzendorf
>> <wkerzendorf at gmail.com> wrote:
>>> Hello,
>>> 
>>> I'm looking for a fixed format table reader. Fixed format like in the
>>> fortran definition(no spaces, just a prescribed formatting).
>>> 
>>> e.g. FORMAT(F11.4,F7.3,F6.2,F12.3,F5.2,1X,A10,F12.3,F5.2,1X,A10,
>>> 
>>> 3F6.2,A4,2I2,I3,F6.3,I3,F6.3,2I5,1X,A1,A1,1X,A1,A1,i1,A3.2I5,I6)
>>> 
>>> 
>>> Does atpy do that? Is there any other package that does that or do I need to
>>> role my own?
>> 




More information about the AstroPy mailing list