有没有办法使用 spssaux.GetValuesFromXMLWorkspace 从频率表中检索 python 中的 SPSS 输出数据?

发布于 2025-01-11 19:08:33 字数 960 浏览 3 评论 0原文

我正在尝试用 python 从 SPSS 输出中检索数据,这样我就可以修改数据并将其写入 Excel。使用以下代码从描述表检索数据没有问题:

import spssaux
variables = 'Age'
vDict = spssaux.VariableDict(caseless=True)
vList = vDict.expand(variables)
cmd = spssaux.CreateXMLOutput('descriptives %s.'%" ".join(vList))
ageMax = spssaux.GetValuesFromXMLWorkspace(cmd,'Descriptive Statistics',colCategory = 'Maximum',cellAttrib = 'number')
ageMax = int(ageMax[0])
print(ageMax)

但是当我想从频率表中提取数据时,我无法检索任何数据。

我尝试使用“OMS 逻辑”(表子类型或标签的名称),但仍然没有结果。 我正在使用 SPSS Statistics 26。

这是我到目前为止尝试过的(部分)代码:

import spssaux
variables = 'Age'
vDict = spssaux.VariableDict(caseless=True)
vList = vDict.expand(variables)
cmd = spssaux.CreateXMLOutput('fre %s.'%" ".join(vList))
agePercentage1 = spssaux.GetValuesFromXMLWorkspace(cmd,'Frequencies',colCategory = 'Valid Percent')
agePercentage1 = agePercentage1[0]
print(agePercentage1)

希望有人可以帮助我。

亲切的问候, 巴特

I'm trying to retrieve data from my SPSS output in python, so i can modify the data and write it to excel. I've got no problem retrieving the data from a descriptives table using the following code:

import spssaux
variables = 'Age'
vDict = spssaux.VariableDict(caseless=True)
vList = vDict.expand(variables)
cmd = spssaux.CreateXMLOutput('descriptives %s.'%" ".join(vList))
ageMax = spssaux.GetValuesFromXMLWorkspace(cmd,'Descriptive Statistics',colCategory = 'Maximum',cellAttrib = 'number')
ageMax = int(ageMax[0])
print(ageMax)

But when I want to extract data from a frequency table i'm not able to retrieve any data.

I've tried to use the "OMS logic" (names of Table subtype or labels) but still no result.
I'm using SPSS Statistics 26.

This is (some of) the code i've tried so far:

import spssaux
variables = 'Age'
vDict = spssaux.VariableDict(caseless=True)
vList = vDict.expand(variables)
cmd = spssaux.CreateXMLOutput('fre %s.'%" ".join(vList))
agePercentage1 = spssaux.GetValuesFromXMLWorkspace(cmd,'Frequencies',colCategory = 'Valid Percent')
agePercentage1 = agePercentage1[0]
print(agePercentage1)

Hopefully somebody can help me.

Kind regards,
Bart

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文