[AstroPy] extracting column names

Susana Sanchez Exposito sse at iaa.es
Mon Feb 25 06:03:48 EST 2013


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.

Thanks,
Susana.



table = parse_single_table("/home/susana/Documents/examples/tables/cig22.xml",pedantic=False)
data = table.array
dtype_a=data.dtype
column_names=[]
for k,v in dtype_a.fields.iteritems():
    column_names.append(k)

-- 
Susana Sánchez Expósito

Instituto de Astrofísica de Andalucía   IAA (CSIC)
Camino Bajo de Huétor, 50. Granada E-18008
Tel:(+34) 958 121 311 / (+34) 958 230 618
Fax:(+34) 958 814 530
e-mail: sse at iaa.es



More information about the AstroPy mailing list