【问题标题】:How to open or convert SPSS (.sav) file into CSV using Python - Pandas?如何使用 Python - Pandas 打开 SPSS (.sav) 文件或将其转换为 CSV?
【发布时间】:2020-06-19 09:19:48
【问题描述】:

我有 .sav 文件,我需要将其转换为 csv 文件。

我尝试使用导入 savReaderWriter 库,但它不起作用。我收到此错误:

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

我知道在 R 中它可能更容易,但我真的需要在 Python 中。有什么帮助吗?

【问题讨论】:

标签: python pandas spss spss-modeler


【解决方案1】:

尝试使用 pyreadstat:

import pyreadstat

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

df.to_csv("mycsv.csv")

你必须安装它:

pip install pyreadstat

更多信息在这里:

https://github.com/Roche/pyreadstat

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-13
    • 2017-07-20
    • 1970-01-01
    • 2017-06-01
    • 2018-12-09
    相关资源
    最近更新 更多