Skip to content

BUG: reading space-delimited CSV file and skipping first row with double quote in it fails #62739

@taldcroft

Description

@taldcroft

Pandas version checks

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

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

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
from pathlib import Path
# Bug is triggered when the first line has a double quote character
tbl = """\
"
a b
1 3
"""
Path("tbl.csv").write_text(tbl)
pd.read_csv("tbl.csv", delimiter=" ", skiprows=1)

Issue Description

This results in an exception:

Traceback (most recent call last):
  Cell In[1], line 9
    pd.read_csv("tbl.csv", delimiter=" ", skiprows=1)
  File ~/miniconda3-arm/envs/astropy-dev/lib/python3.13/site-packages/pandas/io/parsers/readers.py:1026 in read_csv
    return _read(filepath_or_buffer, kwds)
  File ~/miniconda3-arm/envs/astropy-dev/lib/python3.13/site-packages/pandas/io/parsers/readers.py:620 in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File ~/miniconda3-arm/envs/astropy-dev/lib/python3.13/site-packages/pandas/io/parsers/readers.py:1620 in __init__
    self._engine = self._make_engine(f, self.engine)
  File ~/miniconda3-arm/envs/astropy-dev/lib/python3.13/site-packages/pandas/io/parsers/readers.py:1898 in _make_engine
    return mapping[engine](f, **self.options)
  File ~/miniconda3-arm/envs/astropy-dev/lib/python3.13/site-packages/pandas/io/parsers/c_parser_wrapper.py:93 in __init__
    self._reader = parsers.TextReader(src, **kwds)
  File parsers.pyx:581 in pandas._libs.parsers.TextReader.__cinit__
EmptyDataError: No columns to parse from file

Expected Behavior

This should skip the first line and return a dataframe:

>>> pd.read_csv("tbl.csv", delimiter=" ", skiprows=1)
   a  b
0  1  3

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.13.2
python-bits : 64
OS : Darwin
OS-release : 23.4.0
Version : Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.3
numpy : 2.2.3
pytz : 2025.1
dateutil : 2.9.0.post0
pip : 24.2
Cython : None
sphinx : 8.2.3
IPython : 8.32.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.3
blosc : None
bottleneck : 1.4.2
dataframe-api-compat : None
fastparquet : None
fsspec : 2025.2.0
html5lib : 1.1
hypothesis : 6.125.3
gcsfs : None
jinja2 : 3.1.5
lxml.etree : None
matplotlib : 3.10.0
numba : 0.61.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 19.0.0
pyreadstat : None
pytest : 8.3.4
python-calamine : None
pyxlsb : None
s3fs : 2025.2.0
scipy : 1.15.1
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.1
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions