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

fix(rust,python): fix csv parser error when commented-out rows precede the header row #13318

Merged

Conversation

alexander-beedie
Copy link
Collaborator

Closes #13022.

The linked issue mentions raise_if_empty but that's a red herring; the real issue is that we were trying to skip the header row before we had skipped the pre-header rows (including comments), instead of after. Reordering those two operations so that the correct lines are skipped solves the error.

Added some additional comment/skip permutations to the existing test coverage.

Also: the slightly misleadingly-named skip_header function didn't actually have any header-specific logic; was just a simple redirect to skip_this_line, so we may as well just call that directly.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Dec 29, 2023
if self.has_header {
bytes = skip_header(bytes, quote_char, eol_char);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, the argument skip_rows_before_header is pretty clear. ^^

@ritchie46 ritchie46 merged commit 64a66c9 into pola-rs:main Dec 30, 2023
26 checks passed
@alexander-beedie alexander-beedie deleted the fix-csv-comments-preceding-header branch December 30, 2023 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
2 participants