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

BUG: read_csv(on_bad_lines="warn") should raise a UserWarning instead of writing to stderr #54296

Closed
mroeschke opened this issue Jul 28, 2023 · 0 comments · Fixed by #55071
Closed
Labels
IO CSV read_csv, to_csv Warnings Warnings that appear or should be added to pandas

Comments

@mroeschke
Copy link
Member

As the docs state

‘warn’, raise a warning when a bad line is encountered and skip that line.

In [4]: pd.read_csv(StringIO(data), on_bad_lines="warn")
Skipping line 3: expected 1 fields, saw 3
Skipping line 5: expected 1 fields, saw 3

Out[4]: 
   a
0  1
1  4

Since it's not a Python warning it cannot be handled with the warnings module per se.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO CSV read_csv, to_csv Warnings Warnings that appear or should be added to pandas
Projects
None yet
1 participant