Skip to content

Commit 4031217

Browse files
committed
ENH: adding Irsa.list_columns
1 parent fb76dd6 commit 4031217

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

astroquery/ipac/irsa/core.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,5 +321,27 @@ def print_catalogs(self):
321321
for catname in catalogs:
322322
print("{:30s} {:s}".format(catname, catalogs[catname]))
323323

324+
def list_columns(self, catalog, *, full=False):
325+
"""
326+
Return list of columns of a given IRSA catalog.
327+
328+
Parameters
329+
----------
330+
catalog : str
331+
The name of the catalog.
332+
full : bool
333+
If True returns the full schema as a `~astropy.table.Table`.
334+
If False returns a dictionary of the column names and their description.
335+
"""
336+
337+
query = f"SELECT * from TAP_SCHEMA.columns where table_name='{catalog}'"
338+
339+
column_table = self.query_tap(query).to_table()
340+
341+
if full:
342+
return column_table
343+
else:
344+
return {column['column_name']: column['description'] for column in column_table}
345+
324346

325347
Irsa = IrsaClass()

0 commit comments

Comments
 (0)