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.
import pandas as pd from io import StringIO csv = '''example,header 'comma , here',foobar''' pd.read_csv(StringIO(csv), sep=',', quotechar="'") ''' Correct output example header 0 comma , here foobar ''' pd.read_csv(StringIO(csv), sep=',', quotechar="'", engine='pyarrow') ''' Error output: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/homebrew/lib/python3.10/site-packages/pandas/util/_decorators.py", line 211, in wrapper return func(*args, **kwargs) File "/opt/homebrew/lib/python3.10/site-packages/pandas/util/_decorators.py", line 331, in wrapper return func(*args, **kwargs) File "/opt/homebrew/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 950, in read_csv return _read(filepath_or_buffer, kwds) File "/opt/homebrew/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 611, in _read return parser.read(nrows) File "/opt/homebrew/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 1766, in read df = self._engine.read() # type: ignore[attr-defined] File "/opt/homebrew/lib/python3.10/site-packages/pandas/io/parsers/arrow_parser_wrapper.py", line 147, in read table = pyarrow_csv.read_csv( File "pyarrow/_csv.pyx", line 1217, in pyarrow._csv.read_csv File "pyarrow/_csv.pyx", line 1226, in pyarrow._csv.read_csv File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status pyarrow.lib.ArrowInvalid: CSV parse error: Expected 2 columns, got 3: 'comma , here',foobar '''Issue Description
It appears quotechar
is getting ignored. It works if it's double quotes (the default) but no other quote type.
Expected the parse to work (and be the same as non-pyarrow pandas).
I believe the bug is in this bit of code: https://github.com/pandas-dev/pandas/blob/main/pandas/io/parsers/arrow_parser_wrapper.py#L52
Specifically, the pyarrow csv parser seems to want quote_char
and pandas is giving quotechar
, so this mapping probably needs updated. I have not tested this, though.
commit : 2e218d1
python : 3.10.10.final.0
python-bits : 64
OS : Darwin
OS-release : 21.6.0
Version : Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:35 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T8101
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.3
numpy : 1.23.3
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 67.2.0
pip : 23.0
Cython : 0.29.32
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2022.11.0
gcsfs : None
matplotlib : 3.6.2
numba : 0.56.4
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 11.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.9.3
snappy : None
sqlalchemy : 1.4.45
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlwt : None
zstandard : 0.20.0
tzdata : 2022.5
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4