I see the problem looking at the spssdata.ismissing code. It looks like this.
stringmv = isinstance(value, str)
# with long strings, only the first 8 bytes are compared to the defined missing values
# truncating a multibyte/utf-8 string could result in a partial character at the end
# but then the first 8 bytes could not be a missing value anyway.
if stringmv:
value = value[:8].rstrip() # 8-24-2021 add rstrip
if value is None or value in missingtuple[-3:]:
return True
if missingtuple[0] == 0 or stringmv:
return False
At line 809 (version 28), it should be this
value = value[:8].rstrip() # 8-24-2021 add rstrip
I suggest you change the code accordingly. However, there is a comment elsewhere in the module that the rstrip call was removed. I can't see why. Try this change and let me know if everything works for you while I investigate.
You can find the spssdata.py module after the import if you do
print(spssdata)
Jon Peck (
jkpeck@gmail.com)
------------------------------
Jon Peck
------------------------------
Original Message:
Sent: Tue August 24, 2021 02:07 PM
From: Estefano Souza
Subject: Problem with user-missing value identification from string variables (Python class spssdata)
I need help about SPSS Statistics integration with Python 3.
I can't identify user-missing values from string variables with the hasmissing and ismissing methods from Python class spssdata. A single example (syntax file and SPSS Statistics output) is attached. This program block identifies the cases with missing values for the variable numVar, but not the ones for stringVar (case 4 has an user-missing value of stringVar).
------------------------------
Estefano Souza
------------------------------
#SPSSStatistics