简体   繁体   中英

How to open or convert SPSS (.sav) file into CSV using Python - Pandas?

I have .sav file and i need to convert it into csv file.

I tried to use import savReaderWriter library but its not working. I am getting this error:

SPSSIOError: Problem opening file b'C:\\Users\\

I know in R it might be easier but i really need in Python. Any help?

Try with pyreadstat:

import pyreadstat

df, meta = pyreadstat.read_sav(r"C:\path\to\file.sav")

df.to_csv("mycsv.csv")

You have to install it with :

pip install pyreadstat

more information here:

https://github.com/Roche/pyreadstat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM