import arcpy, os, sys, string arcpy.env.overwriteOutput = True fc = "K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\Traffic_Count_Data\2011_Counts\2011_Annual_Stations\Final_Annual_Stations_2012.shp" fields = ("TFLAG", "T_FLAG") Value = "TFLAG" <> "T_FLAG" where = "%s = '%s'" % (field, vlaue) dhList = [] for w in ws: arcpy.env.workspace = w gdb = arcpy.ListWorkspaces ("*", "TFLAG") for fc in gdb: arcpy.env.workspace = fc
import arcpy flayer = "Points" alayer = "PointsAnno" FRows = arcpy.SearchCursor(flayer,"", sort_fields="ID A") ARows = arcpy.SearchCursor(alayer,"", sort_fields="TextString A") FList = [] AList = [] for row in FRows: Fvalue = row.getValue("ID") FList.append(str(Fvalue)) for row in ARows: Avalue = row.getValue("TextString") 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, "SWITCH_SELECTION")
import arcpy, os, sys, string flayer = "AADT" alayer = "AADT AnnoLabel" FRows = arcpy.SearchCursor(flayer,"", sort_fields="FLAG") ARows = arcpy.SearchCursor(alayer,"", sort_fields="TFLAG") FList = [] AList = [] for row in FRows: Fvalue = row.getValue("ID") FList.append(str(Fvalue)) for rows in ARows: Avalue = row.getValue("TextString") 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") Runtime error <type 'exceptions.TypeError'>: SearchCursor() got an unexpected keyword argument 'sort_fields' >>>
import arcpy flayer = "AADT" alayer = "AADTAnnoLabel" FRows = arcpy.SearchCursor(flayer,"", sort_fields="FLAG A") ARows = arcpy.SearchCursor(alayer,"", sort_fields="TFLAG A") FList = [] AList = [] for row in FRows: Fvalue = row.getValue("FLAG") FList.append(str(Fvalue)) for rows 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")