The code I wrote is not right!! It's selecting more than what is actually missing. I think I'm wrong on the matched code line. I need the script to make a list of the "FLAG" field and a list of the "TFLAG" field. Then compare and select all the missing records from the "TFLAG " field. For Example, if 105H10 is missing from the "TFLAG" field then it will select that record in the "FLAG" field so I know to fix it and add the record.
import arcpy, traceback
mxd = arcpy.mapping.MapDocument("CURRENT")
lstLayers = arcpy.mapping.ListLayers(mxd)
flayer = arcpy.mapping.ListLayers(mxd, "AADT")[0]
alayer = arcpy.mapping.ListLayers(mxd, "AADTAnnoLabel")[0]
FRows = arcpy.SearchCursor(flayer)
ARows = arcpy.SearchCursor(alayer)
ffields = arcpy.ListFields(flayer, "FLAG", "String")
afields = arcpy.ListFields(alayer, "TFLAG", "String")
FList = []
AList = []
for row in FRows:
Fvalue = row.getValue("FLAG")
FList.append(str(Fvalue))
for row in ARows:
Avalue = row.getValue("TFLAG")
AList.append(str(Avalue))
matched = set(FList) & set(AList)
for x in matched:
print x
exp = '"FLAG" = ' + "'" + x + "'"
arcpy.SelectLayerByAttribute_management("AADT", "ADD_TO_SELECTION", exp)
arcpy.SelectLayerByAttribute_management("AADT", "SWITCH_SELECTION")