I am comparing fields in layers. I have the AADT layer and AADTAnno layer and I want it to search the fields FLAG and TFLAG. For Example: If there is a 29C9 in AADT layer in FLAG fields then there needs to be the same thing in the ANNo layer in the TFLAG field. My code stops running on my for row in FRows command line. I think its because I'm not letting it know that FLAG is the field. Please help!!
New Code!!
import arcpy, traceback
mxd = arcpy.mapping.MapDocument(r"K:\TASS\2 - GEO-DATA PROCESSING SUPPORT\MICHELLE'S WORK_ENTER NOT!!\Work Folder\Python Programming\Wayne's Tools\Abilene_Base_Map.mxd")
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")
afields = arcpy.ListFields(alayer, "", "TFLAG")
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:
exp = "ID = " + x
arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")
FLAG
field actually exist in the feature class referenced byflayer
? I also get a 999999 error if I refer to a nonexistent field in the argument togetValue
. – blah238 Apr 25 at 20:21