Skip to content

Commit

Permalink
BUG: fix write/read roundtrips with empty Table dumped to ECSV
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Jan 15, 2024
1 parent 9d3cfcb commit 451f438
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions astropy/io/ascii/ecsv.py
Expand Up @@ -176,8 +176,13 @@ def get_cols(self, lines):

# Read the first non-commented line of table and split to get the CSV
# header column names. This is essentially what the Basic reader does.
header_line = next(super().process_lines(raw_lines))
header_names = next(self.splitter([header_line]))
try:
header_line = next(super().process_lines(raw_lines))
header_names = next(self.splitter([header_line]))
except StopIteration:

Check warning on line 182 in astropy/io/ascii/ecsv.py

View check run for this annotation

Codecov / codecov/patch

astropy/io/ascii/ecsv.py#L182

Added line #L182 was not covered by tests
# there are no non-commented lines
header_line = ""
header_names = []

Check warning on line 185 in astropy/io/ascii/ecsv.py

View check run for this annotation

Codecov / codecov/patch

astropy/io/ascii/ecsv.py#L184-L185

Added lines #L184 - L185 were not covered by tests

# Check for consistency of the ECSV vs. CSV header column names
if header_names != self.names:
Expand Down
1 change: 1 addition & 0 deletions docs/changes/units/15885.bugfix.rst
@@ -0,0 +1 @@
Fix write/read roundtrips with empty ``Table`` dumped to ECSV.

0 comments on commit 451f438

Please sign in to comment.