Skip to content

Commit

Permalink
BUG: fix write/read roundtrip 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 8305441
Showing 1 changed file with 7 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:
# there are no non-commented lines
header_line = ""
header_names = []

# Check for consistency of the ECSV vs. CSV header column names
if header_names != self.names:
Expand Down

0 comments on commit 8305441

Please sign in to comment.