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: read_csv for empty lines #11924

Merged
merged 3 commits into from
Oct 22, 2023
Merged

fix: read_csv for empty lines #11924

merged 3 commits into from
Oct 22, 2023

Conversation

uchiiii
Copy link
Contributor

@uchiiii uchiiii commented Oct 21, 2023

To fix #11611

@stinodego stinodego changed the title Fix csv reader fix: read_csv for empty files Oct 21, 2023
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Oct 21, 2023
@stinodego stinodego changed the title fix: read_csv for empty files fix: read_csv for empty lines Oct 21, 2023
@@ -350,14 +350,19 @@ pub fn infer_file_schema_inner(
// keep track so that we can determine the amount of bytes read
end_ptr = line.as_ptr() as usize + line.len();

let len = line.len();

if len == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

if line.is_empty()

use_pyarrow=False,
)
expected = pl.DataFrame({"A": ["a", None, "b"]})
print(df)
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the print?

use_pyarrow=False,
)
expected = pl.DataFrame({"A": ["a", "c"], "B": ["b", "d"]})
print(df)
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the print?

@ritchie46
Copy link
Member

Thank you @uchiiii

@ritchie46 ritchie46 merged commit 5993a57 into pola-rs:main Oct 22, 2023
24 checks passed
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
Development

Successfully merging this pull request may close these issues.

read_csv: CSV file with 1 column and an empty line gives index out of bounds: the len is 0 but the index is 0/
2 participants