Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 3 tasks
galipremsagar opened this issue Nov 4, 2020 · 2 comments
Closed
2 of 3 tasks
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@galipremsagar
Copy link

  • 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

@galipremsagar galipremsagar added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 4, 2020
@ivanovmg
Copy link
Member

The same code snippet works on master.
Se details below.

Python 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 18:22:52) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pandas as pd

In [2]: df = pd.read_parquet('temp.parquet')

In [3]: df
Out[3]:
0 1 2 3 4 ... 24 25 26 27 28
0 38336 ... 2028304185033190912
1 True 38521 ...
2 True 5054 3271915117 33317 ... 1188716756 39682
3 -31346 18758 ... 1087642002 14202 -4248617305981604864 3122060888
4 True 48376 ... 2207089175 -7541642907968846848 747124512
.. ... ... ... ... ... ... ... ... ... ... ...
813 True 15428 ... 62110627
814 False -14583 33022 ...
815 42803 ... 3767148217
816 False 1403 29621 ... 1746560190 38487 1941864748
817 True 1725560642 12305 ... 399893360 9185 3137914998

[818 rows x 29 columns]

In [4]: df.to_csv('temp.csv')

In [5]: pd.read_csv('temp.csv')
Out[5]:
Unnamed: 0 0 1 2 3 ... 24 25 26 27 28
0 0 NaN NaN NaN NaN ... NaN NaN 2.028304e+18 NaN NaN
1 1 NaN True NaN NaN ... NaN NaN NaN NaN NaN
2 2 NaN True 5054.0 3.271915e+09 ... 1.188717e+09 39682.0 NaN NaN NaN
3 3 NaN NaN -31346.0 NaN ... 1.087642e+09 14202.0 -4.248617e+18 NaN 3.122061e+09
4 4 NaN True NaN NaN ... 2.207089e+09 NaN -7.541643e+18 NaN 7.471245e+08
.. ... .. ... ... ... ... ... ... ... .. ...
813 813 NaN True NaN NaN ... NaN NaN NaN NaN 6.211063e+07
814 814 NaN False -14583.0 NaN ... NaN NaN NaN NaN NaN
815 815 NaN NaN NaN NaN ... NaN NaN NaN NaN 3.767148e+09
816 816 NaN False 1403.0 NaN ... 1.746560e+09 38487.0 NaN NaN 1.941865e+09
817 817 NaN True NaN 1.725561e+09 ... 3.998934e+08 9185.0 NaN NaN 3.137915e+09

[818 rows x 30 columns]

In [6]: pd.show_versions()

INSTALLED VERSIONS

commit : cf31d1b
python : 3.8.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1251

pandas : 1.2.0.dev0+1124.gcf31d1ba5
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.4
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.6.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.8.4
fastparquet : 0.4.1
gcsfs : 0.7.1
matplotlib : 3.3.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 2.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.0
sqlalchemy : 1.3.20
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.51.2

@mroeschke
Copy link
Member

Sounds like this may have been fixed in a version > 1.2.0. Closing since this is working, but happy to reopen if this issue persists on a more recent version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

3 participants