Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If skip_blank_lines is False in CSVReader, garbage data is read out in all cases #158

Open
ptgolden opened this issue Oct 31, 2024 · 2 comments
Assignees

Comments

@ptgolden
Copy link
Member

The second clause here should be elif not row or elif row == [].

if self.skip_blank_lines:
while not row:
row = next(self.reader)
else:
row = ['NaN' for _ in range(len(self._header))]

Since it's not, if skip_blank_lines=False is passed to the reader, then in all cases, every value read will be 'NaN' for str types, nan for float types, and raise an error for int types.

I'm surprised no one has ever run into this-- it suggests that no one has ever used the non-default option of skip_blank_lines.

@ptgolden ptgolden self-assigned this Oct 31, 2024
@ptgolden
Copy link
Member Author

It looks like that clause was introduced in 80cf068, which means 3 years and no reports of output consisting solely of "NaN"

@ptgolden
Copy link
Member Author

ptgolden commented Nov 1, 2024

skip_blank_lines is never set to false, because it's not passed to the CSVReader constructor when reading a source:

CSVReader(
resource_io,
name=config.name,
field_type_map=config.field_type_map,
delimiter=config.delimiter,
header=config.header,
header_delimiter=config.header_delimiter,
header_prefix=config.header_prefix,
comment_char=self.config.comment_char,
row_limit=self.row_limit,
)

Can we remove this option? Either blank lines can always be skipped (which is the current behavior), or they can cause an error (due to being malformed CSV).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant