Select to view content in your preferred language

Referencing joined fields in python

522
0
04-07-2010 12:48 PM
ChrisMathers
Regular Contributor II
The title really says it all. I have a script I am working on that will run through my parcel data using an update cursor and calculate the percent change between the appraised value of the last parcel update and the current one. I just dont know how to refer to the joined fields. I made the following as a learning exercise/proof of concept and it works but I am doing the calculations on two fields in the same shapefile. I need to do the calculation on two fields from joined shapefiles.

import arcgisscripting
gp=arcgisscripting.create()

try:
    gp.Workspace=r"C:\GIS Projects\sandbox"
    updCursor=gp.UpdateCursor("New_Shapefile(2).shp")
    row=updCursor.Next()
    counter=1
    while row:
        C=row.GetValue("C")
        D=row.GetValue("D")
        C=float(C)
        D=float(D)
        pctchg=((D-C)/C)*100
        row.SetValue("CtoD", pctchg)
        updCursor.UpdateRow(row)
        print "Updated Record: " + str(counter)
        counter=counter+1
        row=updCursor.Next()
    print "Complete"
    del updCursor
except:
    print gp.GetMessages()
0 Kudos
0 Replies