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_Table and Read_Csv does not raise when delim_whitespace=True and sep=default is given #36583

Closed
3 tasks done
phofl opened this issue Sep 23, 2020 · 6 comments · Fixed by #36709
Closed
3 tasks done
Assignees
Labels
Bug IO CSV read_csv, to_csv
Milestone

Comments

@phofl
Copy link
Member

phofl commented Sep 23, 2020

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import io
f = io.StringIO("a  b  c\n1 -2 -3\n4  5   6")
df = pd.read_table(f, sep="\t", delim_whitespace=True)
df = pd.read_csv(f, sep=",", delim_whitespace=True)

Problem description

Both statement should raise a ValueError

Expected Output

ValueError

Must also edit docs. See #36560 for discussion.

cc @simonjayhawkins

Output of pd.show_versions()

master

@phofl phofl added Bug Needs Triage Issue that has not been reviewed by a pandas team member IO CSV read_csv, to_csv and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 23, 2020
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Sep 23, 2020
@OlehKSS
Copy link
Contributor

OlehKSS commented Sep 27, 2020

Hi, does anyone work on this issue? I want to contribute

@phofl
Copy link
Member Author

phofl commented Sep 27, 2020

Hi, not as far as I now. Please check the discussion in the PR mentioned above and the related issues before starting

@OlehKSS
Copy link
Contributor

OlehKSS commented Sep 27, 2020

Thanks for the quick reply, I'll take it

@OlehKSS
Copy link
Contributor

OlehKSS commented Sep 27, 2020

As far as I see, this bug is due to the fact that in both cases the explicitly provided values of separators are equal/identical to their default values. When pandas compares whether a separator/delimiter value was given, it checks it against these default values. No ValueError was raised in both statements because no default value was changed as if no separator was provided explicitly.

One possible solution might be setting all default values to None and assigning their proper values later. In my opinion, it is possibly going to break automatical detection of separators, i.e. if sep is None, the Python parsing engine (not C) will be used to automatically detect the separator.

@phofl
Copy link
Member Author

phofl commented Sep 27, 2020

None won‘t work. Please read the discussions in #36381 and #36560. The Solution is already discussed there

@OlehKSS
Copy link
Contributor

OlehKSS commented Sep 28, 2020

Based on those discussions I see that you use lib.no_default as a sentinel object. I'll apply it here

@jreback jreback modified the milestones: Contributions Welcome, 1.2 Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants