Skip to content

CSV files with header break with delim_whitespace and skiprows using the C-engine #18692

Closed
@rgieseke

Description

@rgieseke

Code Sample, a copy-pastable example if possible

# Python 3
import pandas as pd
from io import StringIO
data = """Meta:
x " <- Space before quote char

id  value
1  10
2  20
"""
pd.read_csv(StringIO(data), delim_whitespace=True, skiprows=3)

Problem description

When there is a quote char with a space before and using delim_whitespace=True and skiprows reading a CSV file breaks with

EmptyDataError: No columns to parse from file

Expected Output

It should simply skip the header rows.

When using the Python engine it works, so this seems to be a problem with the C-based parser, possibly related to the behaviour introduced in #12900

# This works (with the Python engine):
import pandas as pd
from io import StringIO
data = """Meta:
x " <- Space before quote char

id  value
1  10
2  20
"""
pd.read_csv(StringIO(data), delim_whitespace=True, skiprows=3, engine="python")

My real data has something like

x = "   "

I also tested this with current master.

Output of pd.show_versions()


commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.10.0-40-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.21.0
pytest: 3.3.1
pip: 9.0.1
setuptools: 38.2.4
Cython: 0.27.3
numpy: 1.13.3
scipy: None
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

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