I'm trying to create a script that will traverse through a giant attribute table (comprised of the records of 68 polygons), and total up the values in a particular field for features within each polygon. I want the script to go through the table, look for polygon 1 records, add all values in the "Grand_Tota" field, the move on to looking for all records that comprise polygon 2, and so on.
I haven't used Lists too often so perhaps my problem lies there.
When I run the code now, it just spits keeps spitting out the first total (5).
Each polygon feature is weirdly named "Location X : 0 - 5" where X is the loc number.
fc = "C:\Users\surbemi\Desktop\New folder\Export_Output.shp"
field = "Grand_Tota"
sCursor = arcpy.SearchCursor(fc)
loc = 1
polyName = "Name" # Names are formatted ("Location X : 0 - 5") where X = loc
sum = 0
total = 
while loc < 21:
for row in sCursor:
if row.getValue(polyName) == "Location " + str(loc) + " : 0 - 5":
i = row.getValue(field)
sum = sum + i
print "Location " + str(loc) + " Total: " + str(int(total[loc-1]))
sum = 0
loc = loc + 1