list2 = [] rows = arcpy.SearchCursor(fc) for row in rows: utc_ft = row.getValue("UTC10_Ft") list2.append(utc_ft) tot_utc_ft = sum(list2) arcpy.CalculateField_management(parcels, "Tot_UTC_Pct", """!UTC10_Ft! / tot_utc_ft""", "PYTHON")
Hi,
I'm trying to create a single scalar value as the sum of a row, then use the scalar in a field calculation:
I want the sum of "UTC10_FT" call it tot_utc_ft, then use that value in a calculate field:
to find the sum value:list2 = [] rows = arcpy.SearchCursor(fc) for row in rows: utc_ft = row.getValue("UTC10_Ft") list2.append(utc_ft) tot_utc_ft = sum(list2) arcpy.CalculateField_management(parcels, "Tot_UTC_Pct", """!UTC10_Ft! / tot_utc_ft""", "PYTHON")
Currently getting this error:
tot_utc_ft = sum(list)
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'
I'm sure this is something simple, but admittedly, not a great python programmer.
The next question will be whether python will use my tot_utc_ft variable within field calculator? Or, do I need to perform this operation within an expression?
Thanks for your help.
rich