<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at. The query string (? and beyond) may be truncated.>
<In what way does your code behave incorrectly? Include ALL error messages.>
This is one of the functions in a soundex module I’m running to deal with SPSS data. It used to work, years ago, but now it generates “Error Computing Case” for each case. Anyone have an idea why this might be happening??
<What do you expect to happen instead?>
def spssoundex(newvariablename,computingvariable):
import spss
varnames =
varcount = spss.GetVariableCount()
for i in xrange(varcount):
varnames.append(spss.GetVariableName(i))
varindex = varnames.index(computingvariable)
cursor = spss.Cursor(accessType = ‘w’)
cursor.SetVarNameAndType([newvariablename],[4])
cursor.CommitDictionary()
for i in range(cursor.GetCaseCount()):
indcursor = cursor.fetchone()
try:
cursor.SetValueChar(newvariablename,get_soundex(indcursor[varindex]))
cursor.CommitCase()
except:
print “Error Computing Case”
try:
print casecursor[varnames.index(“CASE”)]
except:
print “CASE variable not in file”
cursor.close
<do not remove the three backticks above>