I need to create a python script that sums a column's values in a table. Thereafter, the script is supposed to get the percentage of each individual row in that column and populate this percentage values in a another column. I been struggling for quite some time now, I checked the net, but there is nothing of this sort. The nearest is an ArcGIS Discussion Forum thread, but its for an older version of ArcMap, or I am using it wrong.
import arcgisscripting, sys
gp = arcgisscripting.create()
intable = sys.argv[1]
field = sys.argv[2]
# Create search cursor
rows = gp.SearchCursor(intable)
row = rows.Next()
x = 0.0
# Enter while loop for each feature/row
while row:
x += row.getvalue(field)
print x
row = rows.next()
#note value can be rounded depending on field type
gp.calculatefield(intable,sys.argv[3],float(x),"PYTHON")
Best Answer
try this: