Description
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 csv
import pandas as pd
one_col_csv = """HEADER
hzhrzhjtrj
rzthyy
azr231
zrhtzrh
zrhtzrh"""
with open("dummy.csv", "w") as file:
file.write(one_col_csv)
print(pd.read_csv("dummy.csv", sep=None))
#Bad detection of the separator, but no error
# According to the doc, csv sniffer is used in backend
# So I also tested it:
with open("dummy.csv") as fp:
print(csv.Sniffer().sniff(fp.read(5000)).delimiter)
# Throw an error "Could not determine delimiter" (which is better)
Issue Description
When pd.reader is used with the parameter sep=None, it failed to automaticaly detect signle column csv.
I have already read this conversation (2016): #13839
They had the same problem but come to the conclusion that the error comes csv sniffer python library.
But I think this is no longer relevant as csv.sniffer now raise an error when pandas still insist on parsing it wrong.
Expected Behavior
It should automatically detect it is a single column file, or at least raise an error.
Installed Versions
INSTALLED VERSIONS
commit : 37ea63d
python : 3.8.16.final.0
python-bits : 64
OS : Linux
OS-release : 5.19.0-41-generic
Version : #42~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 18 17:40:00 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.0.1
numpy : 1.23.0
pytz : 2023.3
dateutil : 2.8.2
setuptools : 67.6.1
pip : 23.1
Cython : 0.29.34
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.12.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.1
numba : 0.56.4
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.0
snappy : None
sqlalchemy : 2.0.9
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None