AnsweredAssumed Answered

Using two cursors in a single DBF table

Question asked by James_Seay on Oct 15, 2013
Latest reply on Oct 16, 2013 by James_Seay
I am new to Python and am attempting to write a script which will cycle through the records of a target DBF table. This script would cycle through each record, taking the value in 'field2' and searching the 'field1' attributes for the record with matching attributes. Once the match is found, the script would read the 'field3' value from the second record and apply that value to the original record's 'field4' value.

import arcpy   fc = "U:/Seay/Blanset_work_requests/nhdplus_work1.dbf" field1 = "FromNode" field2 = "ToNode" field3 = "GNIS_ID" field4 = "RWAT" cursorA = arcpy.da.UpdateCursor(fc,[field1, field2, field3, field4]) rowA =   while rowA:  f = rowA.GetValue(field2)  r = rowA.GetValue(field4)  cursorB = arcpy.da.SearchCursor(fc)  rowB =  while rowB:   t = rowB.GetValue(field1)   if t == f:    g = rowB.GetValue(field3)    rowA.SetValue(field4, g)   rowB  cursorA.updateRow(rowA) del cursorA del cursorB  del rowA del rowB

Thank you. Any suggestions would be appreciated.