question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

io.ascii should name columns starting from 'col0' not 'col1'

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
astrofrogcommented, Apr 1, 2018

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)

1reaction
hamogucommented, Mar 6, 2018

I agree with @Gabriel-p that starting with col0 would 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.)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found