ResourceWarning when reading ascii tables
See original GitHub issueUsing an example ecsv file from the astropy documentation:
# %ECSV 0.9
# ---
# datatype:
# - {name: a, unit: m / s, datatype: int64, format: '%03d'}
# - {name: b, unit: km, datatype: int64, description: This is column b}
a b
001 2
004 3
(although this works for anything I tried, including rdb files) when I try to read it with a python with warnings enabled (e.g. python -Wd
) I get a resource warning:
>>> Table.read("test.ecsv")
/Users/timj/work/lsstsw3/miniconda/envs/lsst-scipipe/lib/python3.7/site-packages/astropy/io/ascii/connect.py:37: ResourceWarning: unclosed file <_io.TextIOWrapper name='test.ecsv' encoding='UTF-8'>
return read(filename, format=format, **kwargs)
<Table length=2>
a b
m / s km
int64 int64
----- -----
001 2
004 3
Specifying the format on the read does not trigger a warning:
>>> Table.read("test.ecsv", format="ascii.ecsv")
<Table length=2>
a b
m / s km
int64 int64
----- -----
001 2
004 3
and neither does using astropy.io.ascii.read
directly. So far “ascii.rdb” also behaves like this but “ascii.latex” does not.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
ASCII Tables (astropy.io.ascii) — Astropy v5.2
astropy.io.ascii provides methods for reading and writing a wide range of ASCII data table formats via built-in Extension Reader Classes.
Read more >Reading and Writing tabular ASCII data
Astronomers love storing tabular data in human-readable ASCII tables. ... One of these is the file() object which can be used to read...
Read more >The Python Standard Library — Python 3.11.1 documentation
Python's standard library is very extensive, offering a wide range of facilities as indicated by the long table of contents listed below.
Read more >Reading an "ascii" table that is unicode · Issue #3826 - GitHub
The ESO archive contains some tables that include unicode characters, e.g. csv tables. For example, here's one in raw form: 'Release Date ...
Read more >Python ASCII Reading tables - Stack Overflow
What I did. I separated columns and added to different lists. Now I have got access for different columns:
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 FreeTop 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
Top GitHub Comments
Fast reader does not seem to be the issue:
These messages still appear when testing 4.1:
And more of the same type for many different file type tests.