asdf icon indicating copy to clipboard operation
asdf copied to clipboard

How to read astropy tables with `asdftool`?

Open ketozhang opened this issue 3 years ago • 3 comments

Given an astropy table, how do I use asdftool to read the tabular data (i.e., under the key data).

from astropy.table import Table

table = Table({"colname": list(range(10))})
table.write("data.asdf", format="asdf")

I thought it be asdftool info --show-value data.asdf, but the flag makes no difference.

ketozhang avatar Jan 19 '22 20:01 ketozhang

This seems to just be the limitation and intention of info and that asdftool is missing a CLI command that prints AsdfFile::tree.

ketozhang avatar Jan 20 '22 01:01 ketozhang

It wasn't the intent of info to look at the data, whether image or table. It does suggest that a utility like that would be useful (probably separate ones for simple arrays and tables). Info was more intended to examine the structure of the file (meta data and the location within the tree of any data). So it is a good suggestion that such utilities would be useful, mainly for the shell command line.

perrygreenfield avatar Jan 20 '22 13:01 perrygreenfield

Sorry, I did not write clearly. I completely agree info is for a structural preview of the tree.

Anyways, adding a full printout command (e.g., asdftool tree FILE returns pretty print JSON) is something I can take a stab at contributing (checking if @drdavella @mdboom have considered this).

ketozhang avatar Jan 21 '22 01:01 ketozhang