[AstroPy] extracting column names from VOtable
Mon Feb 25 10:18:32 CST 2013
The first way you say ([f.name for f in table.fields]) it is just what
I am looking for, but the alternative way, using the dtype array
(table.array.dtype.names), does not give the same things. In those
cases when the votable fields contain 'ID' and 'name', the
table.array.dtype.names gives the values in 'ID' but not in 'name'.
2013/2/25 Erik Tollerud <email@example.com>:
> This is probably the easiest way:
> [f.name for f in table.fields]
> ``table.fields`` is a list of `astropy.io.votable.tree.Field` objects, and
> those objects have all the information about the columns (including
> things like units).
> An alternative is to use `array` to get the numpy array from the
> votable, and the `dtype` has the column names. I.e.,
> ``table.array.dtype.names`` should give the same thing. That won't
> include extra VO information like units and such, though.
> On Mon, Feb 25, 2013 at 6:26 AM, Susana Sanchez <firstname.lastname@example.org> wrote:
>> Hi all,
>> Probably this is a newbie question, but how can I extract the names of
>> the columns from the VOtable with the Astropy library?
>> I want to show the VOTable data in a nice way, using the Qt library,
>> so I need to extract the names of the columns and the data from a
>> VOTable. I have tried it using the Numpy record array associated to
>> the votable, see code below. But I have problems when the votable
>> fields have 'ID' and also 'name'. I am wondering if there is a better
>> way to find the column names.
>> I would be very gratefully, If anyone can help me or give me any hint.
>> table = parse_single_table("/home/susana/Documents/examples/tables/cig22.xml",pedantic=False)
>> data = table.array
>> for k,v in dtype_a.fields.iteritems():
>> AstroPy mailing list
More information about the AstroPy