SPSS 15 I/O DLL:修改现有案例
我正在用 C++ 编写一个应用程序,使用 SPSS 15 的 I/O DLL 与 SPSS 15 交互。
我们的 SPSS 数据库由许多案例组成,每个案例都有其独特的“ID”字段。
我需要做的是以读/写方式打开数据库,找到具有匹配 ID 的案例,并根据我的程序解析的 CSV 文件修改一些变量。
从一开始就有 2 种明显的情况:
匹配的情况不存在(在这种情况下,我可以轻松地使用 spssOpenAppend() 添加情况。
存在匹配的情况(这是有问题的情况)
在后者中,我。需要使用 spssOpenWriteCopy() 来获取写入句柄,并使用 spssOpenRead() 来获取读取句柄,虽然我对此不太热衷,但这似乎是使用他们的 DLL 执行此操作的唯一方法。移动写入文件上的案例指针(显然,移动案例指针是只读操作)
这意味着我一直在尝试找出如何修改案例,而不必迭代所有文件并复制所有数据,逐个案例,直到找到我感兴趣的案例。
我想补充一点,升级 SPSS 不是一个选项,
我还想避免必须手动迭代案例并构建新文件。从头开始。
I am writing an application in C++ that interfaces with SPSS 15 using their I/O DLL.
Our SPSS database is made of a number of cases, each with their unique "ID" field.
What I need to do is open the database in read/write, find the case with the matching ID and modify some of the variables according to CSV files that my program parses.
There are 2 obvious cases from the start:
The matching case does not exist (In which case, I can easily use spssOpenAppend() to add the case.
The matching case exists. (And this is the problematic case)
In the latter, I need to use spssOpenWriteCopy() to get a write Handle and spssOpenRead() to have a read handle. While I'm not too keen on that, it seems it's the only way to do it with their DLL. The problem is that I cannot move the case pointer on the write file (Apparently, moving the case pointer is a read-only operation)
That means I am stuck trying to figure out how to modify a case without having to iterate over all the file and copy all the data, case by case, until I find the case I'm interested in.
I'd like to add that upgrading SPSS is not an option.
I'd also like to avoid having to manually iterate case-by-case and build a new file from scratch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想既然问题已经解决了,就没有人会费心去回答了。
无论如何,不可能在数据库中间插入案例。您可以围绕 API 编写包装器来模拟它,但否则,如果不手动迭代每个案例并复制它,就无法完成我想要做的事情。
I figure no one is going to bother answering now that it's solved.
Anyway, it is not possible to insert a case in the middle of a database. You could potentially write wrappers around the API to simulate it, but otherwise there is no way to do what I am trying to do without manually iterating through each case and copying it.