Assertion during creating of multRespDefs
Your example of creating multRespDefs doesn't work
categorical = {"setType": "C", "label": "labelC",
"varNames": ["salary", "educ"]}
dichotomous1 = {"setType": "D", "label": "labelD",
"varNames": ["salary", "educ"], "countedValue": "Yes"}
dichotomous2 = {"setType": "D", "label": "", "varNames":
["salary", "educ", "jobcat"], "countedValue": "No"}
extended1 = {"setType": "E", "label": "", "varNames": ["mevar1",
"mevar2", "mevar3"], "countedValue": "1",
"firstVarIsLabel": True}
extended2 = {"setType": "E", "label":
"Enhanced set with user specified label", "varNames":
["mevar4", "mevar5", "mevar6"], "countedValue":
"Yes", "firstVarIsLabel": False}
multRespDefs = {"testSetC": categorical, "testSetD1": dichotomous1,
"testSetD2": dichotomous2, "testSetEx1": extended1,
"testSetEx2": extended2}
with SavWriter(savFileName, varNames, varTypes, varLabels=varLabels, formats=formats, multRespDefs = multRespDefs, ioUtf8=True) as sav:
for record in records:
sav.writerow(record)
it failed on this line in header.py: 1044
retcode = func(c_int(self.fh), c_char_p(combinedDefs))
with output:
testSetD1 {'varNames': ['salary', 'educ'], 'label': 'labelD', 'countedValue': 'Yes', 'setType': 'D'} D
testSetEx2 {'varNames': ['mevar4', 'mevar5', 'mevar6'], 'firstVarIsLabel': False, 'label': 'Enhanced set with user specified label', 'countedValue': 'Yes', 'setType': 'E'} E
testSetEx1 {'varNames': ['mevar1', 'mevar2', 'mevar3'], 'firstVarIsLabel': True, 'label': '', 'countedValue': '1', 'setType': 'E'} E
testSetD2 {'varNames': ['salary', 'educ', 'jobcat'], 'label': '', 'countedValue': 'No', 'setType': 'D'} D
testSetC {'varNames': ['salary', 'educ'], 'label': 'labelC', 'setType': 'C'} C
python: /buildhome/statbldr/views/builder1unix_spss21000_view/cs_source/Datasource/src/variableset.cpp:163: size_t GetSize(std::string&): Assertion `length != 0' failed.
Is it bug or I just use wrong format?
Thank you in advance
Comments (5)
-
repo owner -
Thank you. Will this patch be available via pip installation?
-
repo owner No, not immediately, but it is possible to pip install straight from the repository:
pip install -U -e git+https://bitbucket.org/fomcl/savreaderwriter.git#egg=savreaderwriter
I realized that I still need to modify the code a little to also make it work in unicode mode (ioUtf8=True). Judging from your name you are from a Slavian country. So instead of switching to unicode mode you might also try setting the SPSS I/O locale to something like ioLocale="ru_RU.cp1251". That has the advantage of smaller file size (utf-8 is bigger than codepage) and greater speed (transcoding causes overhead).
-
Thank you, I will switch standart pip to the repository.
No, I live and work in Germany and I use UTF-8, because we use different languages, not only german. But thank you for this advice and for this plugin.
-
repo owner - changed status to resolved
Fixed. Writing dichotomy MR definitions should work now, including in unicode mode (ioUtf8=True). "Extended" multiple response definitions can only be read, not written (as per documentation).
- Log in to comment
Hi,
This was a bug. Setting categorical MR sets was Ok, the other (dichotomy and extended) was not. I fixed the dichotomy sets. The extended sets still raise an SPSS_INVALID_MRSETDEF exception (sorry). I also added tests. See: https://bitbucket.org/fomcl/savreaderwriter/commits/80a1597b4523b26e731c436afde5e75e9830f635
Thanks! Albert-Jan