Is there a Python module to open SPSS files?(是否有用于打开 SPSS 文件的 Python 模块?)
问题描述
是否有 Python 模块可以打开 IBM SPSS(即 .sav)文件?如果有不需要任何额外 dll 文件/库的最新内容,那就太好了.
Is there a module for Python to open IBM SPSS (i.e. .sav) files? It would be great if there's something up-to-date which doesn't require any additional dll files/libraries.
推荐答案
我发布了一个 Python 包pyreadstat",它可以读取 SPSS(sav、zsav 和 por)、Stata 和 SAS 文件.它是 C 库 ReadStat 的包装器,因此速度非常快.readstat是R库Haven后面用到的库,应用广泛,非常健壮.
I have released a python package "pyreadstat" that reads SPSS (sav, zsav and por), Stata and SAS files. It is a wrapper around the C library ReadStat so it is very fast. Readstat is the library used in the back of the R library Haven, which is widely used and very robust.
该包是自动包含的.它不需要使用 R(不需要安装额外的应用程序)并且它不依赖于 IBM dll 或其他外部库.
The package is autocontained. It does not require using R (no need to install an aditional application) and it does not depend on IBM dlls or other external libraries.
例如,为了读取 SPSS sav 文件,您可以执行以下操作:
For example, in order to read a SPSS sav file you would do:
import pyreadstat
df, meta = pyreadstat.read_sav("/path/to/sav/file.sav")
df 是一个熊猫数据框.Meta 包含元数据,例如变量标签或值标签.read_sav 读取 sav 和 zsav(压缩)文件.还有一个函数 read_por 用于旧的 por(便携式)文件.
df is a pandas dataframe. Meta contains metadata such as variable labels or value labels. read_sav reads both sav and zsav (compressed) files. There is also a function read_por for old por (portable) files.
您可以在这里找到它:https://github.com/Roche/pyreadstat
这篇关于是否有用于打开 SPSS 文件的 Python 模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否有用于打开 SPSS 文件的 Python 模块?


基础教程推荐
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 筛选NumPy数组 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01