Skip to content

BUG: ParserError while reading a csv file generated by pandas dataframe #37620

@galipremsagar

Description

@galipremsagar
  • 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.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

temp.parquet(Please rename the file to temp.parquet, attached by renaming to zip file) :temp.parquet.zip

In[68]: import pandas as pd
In[69]: df = pd.read_parquet('temp.parquet')
In[70]: df
Out[70]: 
        0      1       2  ...                    26    27          28
0    <NA>   <NA>    <NA>  ...   2028304185033190912  <NA>        <NA>
1    <NA>   True    <NA>  ...                  <NA>  <NA>        <NA>
2    <NA>   True    5054  ...                  <NA>  <NA>        <NA>
3    <NA>   <NA>  -31346  ...  -4248617305981604864  <NA>  3122060888
4    <NA>   True    <NA>  ...  -7541642907968846848  <NA>   747124512
..    ...    ...     ...  ...                   ...   ...         ...
813  <NA>   True    <NA>  ...                  <NA>  <NA>    62110627
814  <NA>  False  -14583  ...                  <NA>  <NA>        <NA>
815  <NA>   <NA>    <NA>  ...                  <NA>  <NA>  3767148217
816  <NA>  False    1403  ...                  <NA>  <NA>  1941864748
817  <NA>   True    <NA>  ...                  <NA>  <NA>  3137914998

[818 rows x 29 columns]
In[71]: df.to_csv('temp.csv')
In[72]: pd.read_csv('temp.csv')
Traceback (most recent call last):
  File "/home/pgali/anaconda3/envs/cudf_dev/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3417, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-72-7315a31c9d2d>", line 1, in <module>
    pd.read_csv('temp.csv')
  File "/home/pgali/anaconda3/envs/cudf_dev/lib/python3.7/site-packages/pandas/io/parsers.py", line 686, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "/home/pgali/anaconda3/envs/cudf_dev/lib/python3.7/site-packages/pandas/io/parsers.py", line 458, in _read
    data = parser.read(nrows)
  File "/home/pgali/anaconda3/envs/cudf_dev/lib/python3.7/site-packages/pandas/io/parsers.py", line 1196, in read
    ret = self._engine.read(nrows)
  File "/home/pgali/anaconda3/envs/cudf_dev/lib/python3.7/site-packages/pandas/io/parsers.py", line 2155, in read
    data = self._reader.read(nrows)
  File "pandas/_libs/parsers.pyx", line 847, in pandas._libs.parsers.TextReader.read
  File "pandas/_libs/parsers.pyx", line 862, in pandas._libs.parsers.TextReader._read_low_memory
  File "pandas/_libs/parsers.pyx", line 918, in pandas._libs.parsers.TextReader._read_rows
  File "pandas/_libs/parsers.pyx", line 905, in pandas._libs.parsers.TextReader._tokenize_rows
  File "pandas/_libs/parsers.pyx", line 2042, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.

Problem description

The parse error occurs when we try to read the csv file generated by pandas dataframe. This error occurs to this specific dataframe. Not sure what the reason is. Hence attaching the dataframe in parquet file.

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS

commit : db08276
python : 3.7.8.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-52-generic
Version : #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.3
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.4
setuptools : 49.6.0.post20201009
Cython : 0.29.21
pytest : 6.1.1
hypothesis : 5.37.3
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.8.4
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 1.0.1
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.51.2

Cross referencing to cudf fuzz test thread for tracking: rapidsai/cudf#6001

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