BUG: Formatting issues with stderr output of read_csv() with warn_bad_lines=True #41710
Closed
2 of 3 tasks
Labels
Milestone
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.
Code Sample, a copy-pastable example
badly-formatted.csv
(note extra tab characters)
main.py
Problem description
When using
pandas.read_csv()
with theerror_bad_lines=False
argument (and the defaultwarn_bad_lines=True
arg), the output being printed to stderr appears to bebytes
type that has been cast tostr
. This adds noise to the console output, and is making it difficult to properly capture stderr output from this constructor.Expected stderr Output from MRE
Actual stderr Output from MRE
Inconsistent line breaks with larger files
I have also seen line breaks appear inconsistently when reading in larger files. I haven't been able to isolate any causes of this inconsistency yet
Actual stderr output from large file
Expected stderr output from large file
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.9.5.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
Version : Darwin Kernel Version 18.7.0: Mon Mar 8 22:11:48 PST 2021; root:xnu-4903.278.65~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.4
numpy : 1.19.4
pytz : 2020.5
dateutil : 2.8.1
pip : 21.1.2
setuptools : 56.0.0
Cython : None
pytest : 6.2.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 2.2.5
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: