AnsweredAssumed Answered

Using and Search and Update Data Access Cursors to Populate a Field in a New Table

Question asked by gardta on Jan 29, 2018
Latest reply on Jan 30, 2018 by gardta

I'm assuming this is pretty straightforward, and I am missing something fairly simple. 


I am attempting to bring in a column of data values, 'FieldA', from a table, 'Table_1', to populate an empty field, 'FieldA', in a new, empty table, 'Table_2'. These 'FieldA' values will be used as a key in 'Table 2' for subsequent field calculations. Is there a direct way to do this?


I have been attempting to use a search cursor and update cursor combination to write the field values to the new table, though I am not sure how to successfully employ the cursors to update the single field without an existing key between the two tables (where I would use a dictionary). 


Here is my unsuccessful, botched code:


search_feats = arcpy.da.SearchCursor(Table_1,["FieldA"])

i = 0
with arcpy.da.UpdateCursor(Table_2,["FieldA"]) as upd_cur:
     for upd_row in upd_cur:
         upd_row[0] = search_feats (i)
del upd_cur


What may be a better way to approach this?