有没有办法使用 spssaux.GetValuesFromXMLWorkspace 从频率表中检索 python 中的 SPSS 输出数据?
我正在尝试用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论