Skip to content

Strange behaviour of delim_whitespace in pd.read_table #36381

Closed
@mcocdawc

Description

@mcocdawc
  • 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 pandas as pd
# The error persists with non-empty files
! touch test_file
pd.read_table('./test_file', delim_whitespace=True)

Problem description


~/.local/lib/python3.6/site-packages/pandas/io/parsers.py in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
    623     if delim_whitespace and delimiter != default_sep:
    624         raise ValueError(
--> 625             "Specified a delimiter with both sep and "
    626             "delim_whitespace=True; you can only specify one."
    627         )

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

Expected Output

Parsed dataframe.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 2a7d332
python : 3.6.10.final.0
python-bits : 64
OS : Linux
OS-release : 4.12.14-lp151.28.67-default
Version : #1 SMP Fri Sep 4 15:23:21 UTC 2020 (2c5a14f)
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.2
numpy : 1.17.3
pytz : 2018.5
dateutil : 2.7.3
pip : 19.3.1
setuptools : 40.5.0
Cython : 0.27.3
pytest : None
hypothesis : None
sphinx : 1.7.6
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.0.0
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.4.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 2.0.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.2.0
sqlalchemy : 1.2.14
tables : None
tabulate : 0.8.5
xarray : None
xlrd : None
xlwt : None
numba : 0.48.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions