AnsweredAssumed Answered

Update table attributes from another table

Question asked by CCweedcontrol on Jul 18, 2017
Latest reply on Jul 20, 2017 by CCweedcontrol

I have a table(Table1) that i need to update on a regular basis by comparing/matching the records in the  (Table1) to the table (Table2) based on field "Street" of Table1 and "FullStName" of table two. If theirs NOT a match it then updates the table1 based on the NOT matched from the table and I also need it to add "FullStName" have have "RES", "Reserved", "proposed" in the "status" field of table2. I need to add the missing names of tabel2 to table 1. Hopefully it make sense.


This is what i have but i am not sure i am doing it right...

import arcpy
from arcpy import env

arcpy.env.workspace = r"C:\Temp\Default.gdb\RoadNames"
Rtable = "table1" 
table1 = "table2" 
fcIncident = [] 
tableIncident = [] 
with arcpy.da.SearchCursor(Rtable, ["Street"]) as cursor: 
    for row in cursor: 
del row, cursor 
with arcpy.da.SearchCursor(table1, ["FULLSTNAME", "STATUS"]) as cursor: 
    for row in cursor:
        if row[1] in ("RES", "Reserved", "proposed"):
            if not row[0] in fcIncident: 
del row, cursor 
arcpy.MakeTableView_management(table1, "tblView") 
for ID in tableIncident: 
    arcpy.SelectLayerByAttribute_management("tblView", "ADD_TO_SELECTION", "FULLSTNAME = " + str(ID))