io.ascii should name columns starting from 'col0' not 'col1'
See original GitHub issueWhen using astropy.io.ascii.read to read a file with no header, the columns are named by default as colX where X is a number starting from 1.
This is counter-intuitive to me, as Python reads indexes starting from zero. I would expect the first column to be named col0.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Writing tables — Astropy v1.2.dev14793 - Read the Docs
astropy.io.ascii is able to write ASCII tables out to a file or file-like object ... The data object does not contain information about...
Read more >Writing tables — Astropy v1.0.4
astropy.io.ascii is able to write ASCII tables out to a file or file-like object ... The data object does not contain information about...
Read more >Reading Tables — Astropy v5.2
A common situation is a table with numeric columns but no header row, and in this case astropy.io.ascii will auto-assign column names because...
Read more >astropy.io.ascii.write does funky stuff with quotes in format ...
Well, my problem is not the way quotes are quoted be default, but that it seems to be impossible to make a string...
Read more >python - Adding names and assigning data types to ASCII data
ascii version should work out of the box. If not then io.ascii has a way of reading fixed width tables where you supply...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I wonder if we should keep a list somewhere of ‘known inconsistencies/sub-optimal APIs’ in case we ever develop new APIs? (without breaking old ones)
I agree with @Gabriel-p that starting with
col0would be more in line with normal Python conventions, and is potentially confusing. Thanks a lot for pointing that out.However, @pllim is absolutely right that this would potentially break user code in ways that may not lead to an exception but just silently produce wrong results. I wish we would have chosen 0 originally, but it’s not important enough to potentially break code now and thus I’m deciding to close this for now. Please add comments or re-open if you disagree.
(If you try
tab["col0"]at least you’ll get an error so you know you need to check what’s going on.)