[AstroPy] Access to comments in astropy.io.asccii
Aldcroft, Thomas
aldcroft at head.cfa.harvard.edu
Mon Nov 24 15:18:02 EST 2014
On Sun, Nov 23, 2014 at 12:04 PM, Knox Long <long at stsci.edu> wrote:
> I/we are trying to move to astropy.io.ascii.read for reading ascii.data,
> and for the most part this is working well. However, we often also want
> access to comment lines in our ascii data and I have not found any way to
> do this. Is there something I am missing. Here is an example of what I
> would like to be able to read:
>
> # TITLE= "test.ioncC3.dat"
> # Coord_Sys CYLIND
> x z var inwind i j
> 1.4000e+09 3.5000e+08 0.00e+00 -2 0 0
> 1.4000e+09 8.0805e+08 0.00e+00 -1 0 1
> 1.4000e+09 1.0575e+09 0.00e+00 -1 0 2
> 1.4000e+09 1.3840e+09 0.00e+00 -1 0 3
> 1.4000e+09 1.8113e+09 0.00e+00 -1 0 4
> 1.4000e+09 2.3705e+09 0.00e+00 -1 0 5
> 1.4000e+09 3.1023e+09 0.00e+00 -1 0 6
> 1.4000e+09 4.0600e+09 0.00e+00 -1 0 7
>
Hi Knox,
Getting the comment lines is possible in your case with the following:
>>> from astropy.io import ascii
>>> reader = ascii.get_reader(Reader=ascii.Basic)
>>> dat = reader.read(filename)
>>> comments = reader.comment_lines
This is not terribly convenient, and you cannot guess the format, etc.
I've submitted an issue (https://github.com/astropy/astropy/issues/3136)
and hopefully we can make a better mechanism. This has occurred to me
before as a problem.
Cheers,
Tom
> Thanks,
> Knox
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20141124/864e9e43/attachment.html>
More information about the AstroPy
mailing list