import arcgisscripting gp = arcgisscripting.create() gp.Workspace = "C:/junk/temp.mdb" inputFC = "A" TAB = "B" #Table Loop cur1 = gp.SearchCursor(TAB) row1 = cur1.Next() while row1: #Get the values from the fields(tab) c = row1.GetValue("CATEGORY") s = row1.GetValue("SUBNO") p = row1.GetValue("PROJECT") print "\nc = "+str(c) print "s = "+str(s) print "p = "+str(p) #fc loop cur2 = gp.UpdateCursor(inputFC) row2 = cur2.Next() while row2: #Get the values from the fields(fc) t = row2.GetValue("Category") l = row2.GetValue("LISTNUM") n = row2.GetValue("SUBDIV") print "t = "+t print "l = "+l print "n = "+str(n) #Populate field in the fc based on a match if t == c and l == s: row2.SUBDIV = p #Execute the new value to the fc cur2.UpdateRow(row2) #fc next row2 = cur2.Next() #table next row1 = cur1.Next() del cur2 del cur1 print "\nDone. \n"
Does your code look something like this (other than I changed the table names and mdb name so I would test here).
This code works:import arcgisscripting gp = arcgisscripting.create() gp.Workspace = "C:/junk/temp.mdb" inputFC = "A" TAB = "B" #Table Loop cur1 = gp.SearchCursor(TAB) row1 = cur1.Next() while row1: #Get the values from the fields(tab) c = row1.GetValue("CATEGORY") s = row1.GetValue("SUBNO") p = row1.GetValue("PROJECT") print "\nc = "+str(c) print "s = "+str(s) print "p = "+str(p) #fc loop cur2 = gp.UpdateCursor(inputFC) row2 = cur2.Next() while row2: #Get the values from the fields(fc) t = row2.GetValue("Category") l = row2.GetValue("LISTNUM") n = row2.GetValue("SUBDIV") print "t = "+t print "l = "+l print "n = "+str(n) #Populate field in the fc based on a match if t == c and l == s: row2.SUBDIV = p #Execute the new value to the fc cur2.UpdateRow(row2) #fc next row2 = cur2.Next() #table next row1 = cur1.Next() del cur2 del cur1 print "\nDone. \n"
OK,
1.) copy & paste my code
2.) edit these 3 to match your mdb and file names:
gp.Workspace = "C:/junk/temp.mdb"
InputFC = "A"
TAB = "B"
3.) Let me know what happens.
I added in a few more print commands to see where the code is failing...it looks like the following code is not working for some reason.....maybe it doesn't like using a variable. Like earlier the code runs without any errors but it still doesn't change the name in the SUBDIV field in the FC....I'm stumped.
row2.SUBDIV = p
I know the code works because I've ran it here and it updated the field "SUBDIV". I have to think it's something simple
like a misspelled field name (in the data or the code) or improper indenting or something like that.
I know the code works because I've ran it here and it updated the field "SUBDIV". I have to think it's something simple
like a misspelled field name (in the data or the code) or improper indenting or something like that.
******
Could there be some kind of lock or permission on the FC in the personal geodatabase that is keeping the field SUBDIV from being updated?
rows = gp.SearchCursor("PS_lyr") row = rows.next() try: while row: for i in range(0,numSchools): school = row.GetValue(Elem) M[1] = school M.sort(lambda x, y: cmp(x[1], y[1])) M.reverse() if M[0][1] > 0: school = M[0][0] row.SetValue("[ScenarioTemplate_1011." + String + "]", school) gp.AddMessage("You made it through the if statement") rows.UpdateRow(row) row = rows.next() except: gp.AddError("Failed to set the value of new scenario field to new school assignment")