Search code examples
pythonpandasdataframejupyter-notebookspss

How to open .sav file on Jupyter Notebook?


I am trying to open my .sav file on JUpyter notebook and have tried the following (using pyreadstat) :

import pandas as pd
import pyreadstat

df, meta = pyreadstat.read_sav('filename.sav')

However, the error kept appearing

Invalid file, or file has unsupported features

I have also tried using pandas instead

df = pd.read_spss('filename.sav')

and have received the same error.

My pyreadstat version is 0.3.4 (initially 1.1.0 but failed as well).


Solution

  • Try using this code:

    import pickle
    import pandas
    
    file = open('filename.sav')
    df, meta = pickle.load(file)
    

    hope it works.