Can not open .sav file (spss) in Python (which I had opened last year)

Viewed 1562

I am trying to access a .sav (spss) file which I had opened last year (I don't remember how) but I can't. What can be wrong?

Here is my attempt:

data = pd.read_spss('eleghos_symperiforas.sav')
---------------------------------------------------------------------------
ReadstatError                             Traceback (most recent call last)
<ipython-input-46-a3e3803835b2> in <module>
----> 1 data = pd.read_spss('eleghos_symperiforas.sav')

~\Anaconda3\envs\tf2\lib\site-packages\pandas\io\spss.py in read_spss(path, usecols, convert_categoricals)
     41 
     42     df, _ = pyreadstat.read_sav(
---> 43         path, usecols=usecols, apply_value_formats=convert_categoricals
     44     )
     45     return df

pyreadstat\pyreadstat.pyx in pyreadstat.pyreadstat.read_sav()

pyreadstat\_readstat_parser.pyx in pyreadstat._readstat_parser.run_conversion()

pyreadstat\_readstat_parser.pyx in pyreadstat._readstat_parser.run_readstat_parser()

pyreadstat\_readstat_parser.pyx in pyreadstat._readstat_parser.check_exit_status()

ReadstatError: Invalid file, or file has unsupported features

What would you suggest to do? The file is not corrupt because I got it again from a third source.

1 Answers

I had the same problem. I see that they released pyreadstat version 1.0 on June 2020 (which is the library that pandas uses to open SPSS). I reverted to version 0.3.4 and it was working again.

So:

pip uninstall pyreadstat
pip install pyreadstat==0.3.4
Related