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 raises ValueError when delim_whitespace is set to True #35958

Closed
2 of 3 tasks
cgmorton opened this issue Aug 28, 2020 · 4 comments · Fixed by #36560
Closed
2 of 3 tasks

BUG: read_table raises ValueError when delim_whitespace is set to True #35958

cgmorton opened this issue Aug 28, 2020 · 4 comments · Fixed by #36560
Labels
IO Data IO issues that don't fit into a more specific label Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@cgmorton
Copy link

  • 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.


Code Sample, a copy-pastable example

import io
import pandas as pd

# Build a simple space delimited file buffer to read
f = io.StringIO("a  b  c\n1 -2 -3\n4  5   6")

# This raises an error
df = pd.read_table(f, delim_whitespace=True)

# Setting the "sep" parameter as suggested in the docs works
# df = pd.read_table(f, sep='\s+')
# print(df)

# Not setting the delim_whitespace parameter or setting it to False works, 
#   but without correct formatting.
# df = pd.read_table(f)
# print(df)

Problem description

If you set the delim_whitespace to True when calling read_table() on a space delimited file, I get the following exception:

ValueError: Specified a delimiter with both sep and delim_whitespace=True; you can only specify one.

Expected Output

I would expect the same output as you get if the sep='\s+' parameter is set (as suggested in the docs).

Output of pd.show_versions()

INSTALLED VERSIONS

commit : f2ca0a2
python : 3.6.10.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
Version : Darwin Kernel Version 18.7.0: Thu Jun 18 20:50:10 PDT 2020; root:xnu-4903.278.43~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.1
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.6.0.post20200814
Cython : None
pytest : 5.4.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@cgmorton cgmorton added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 28, 2020
@dsaxton dsaxton added IO Data IO issues that don't fit into a more specific label Regression Functionality that used to work in a prior pandas version and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 28, 2020
@dsaxton
Copy link
Member

dsaxton commented Aug 28, 2020

Thanks @cgmorton. This worked in 1.0.5 so marking as a regression:

In [1]: from io import StringIO
   ...: import pandas as pd
   ...:
   ...: print(pd.__version__)
   ...:
   ...: f = StringIO("a  b  c\n1  2  3\n4  5  6")
   ...: pd.read_table(f, delim_whitespace=True)
   ...:
   ...:
1.0.5
Out[1]:
   a  b  c
0  1  2  3
1  4  5  6

@asishm
Copy link
Contributor

asishm commented Aug 28, 2020

#34976

a7d96fa is the first bad commit
commit a7d96fa
Author: Terji Petersen [email protected]
Date: Thu Jun 25 18:38:08 2020 +0100

TYP: make the type annotations of read_csv & read_table discoverable (#34976)

@dsaxton
Copy link
Member

dsaxton commented Aug 28, 2020

cc @topper-123

@tderond
Copy link

tderond commented Sep 5, 2020

Simply using read_csv in stead of read_table using the exact same arguments seems to work as a workaround for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants