Solved! Go to Solution.
>>> import arcpy >>> shp = r'E:\schoolTestData\schoolJoinToPolys4.shp' >>> query = arcpy.AddFieldDelimiters(shp, 'outGrades') + ' NOT IN (\' \')' >>> print query "outGrades" NOT IN (' ') >>> rows = arcpy.UpdateCursor(shp, query) >>> for row in rows: outGrades = row.outGrades.split(',') outGrades.sort() count = 0 compareVal = outGrades[0] for each in outGrades: if each == compareVal: count += 1 else: if not compareVal in ['KA', 'KP', 'PA', 'PP']: fieldName = 'Grade_' + str(int(compareVal)) else: fieldName = 'Grade_K' count += row.getValue(fieldName) row.setValue(fieldName, count) rows.updateRow(row) count = 1 compareVal = each # load the last unique val if not compareVal in ['KA', 'KP', 'PA', 'PP']: fieldName = 'Grade_' + str(int(compareVal)) else: fieldName = 'Grade_K' count += row.getValue(fieldName) row.setValue(fieldName, count) rows.updateRow(row) >>> del row, rows >>>
Traceback (most recent call last): File "<pyshell#81>", line 21, in <module> fieldName = 'Grade_' + str(int(compareVal)) ValueError: invalid literal for int() with base 10: ''