Sum of product-please help

Nally Kaunda-Bukenya nkaunda at yahoo.com
Fri Sep 3 00:01:10 CEST 2010


Dear all, kindly help me with this code;

This script  is supposed to calculate Rvi for each row by first summing the 
product of #fields (Ai*Rv) and dividing by another field (Tot) such that  
Rvi=sum(Ai*Rv)/Tot. First it's acting like I need another parenthesis and it 
doesn't seem to work at all. i even imported the math module, but not sure if a 
need it. Please advice, your help is highly appreciated.  Please see the code 
below:

import arcpy, math
arcpy.Workspace = "C:\\data\\basins.mdb"
fc = "wshed"
sum = 0
        
# Create the update cursor and advance the cursor to the first row
cur = arcpy.UpdateCursor(fc)
row = cur.Next()
# Perform the update and move to the next row as long as there are
#  rows left
for row:
    row.GetValue(Rvi) = sum(row.Ai*row.Rv)/row.ATot
    cur.UpdateRow(row)
    row = cur.Next()
# Delete the cursors to remove any data locks
del row, cur  


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100902/35d650ff/attachment.html>


More information about the Python-list mailing list