AnsweredAssumed Answered

Compare fields for matches

Question asked by Tonyalmeida on Mar 4, 2020
Latest reply on Mar 4, 2020 by Dan_Patterson

I need to compare fields from two separate tables and mark them with copy or no copy. It seems easy enough but i am having a hard time and not sure what I am doing wrong. I just get all "No" in the Copy field.


Here is what i have.


fc1 = 'C:\Temp\blah1.dbf' 
fc2 = 'C:\Temp\blah2.dbf'

cursor1 = arcpy.da.SearchCursor(fc1, ["Field1", "Copy"]) 
cursor2 = arcpy.da.SearchCursor(fc2, ["Field2"])

with arcpy.da.UpdateCursor(fc1, ['Field1', 'Copy']) as cursor:
    for row in cursor1:
        for row2 in cursor2:
            if row[0].strip().lower()!= row[0].strip().lower():
                for row1 in cursor1:
                    row[1] = 'No'
                    row[1] = 'Copy'
del cursor