import arcpy from arcpy import env mxd = arcpy.mapping.MapDocument("CURRENT") fcList = arcpy.mapping.ListLayers(mxd) jTable = "C:/Users/nwuenstel/Desktop/LocalP/Error_Process/Bangladesh_joinsV.csv" getvalField = "UID5" rows = arcpy.SearchCursor(jTable) for row in rows: row = rows.next() varUID = str(row.getValue(getvalField)) whereExpr = "\"UID\" = '%s'" % varUID arcpy.SelectLayerByAttribute_management("Bng_Line_C", "ADD_TO_SELECTION", whereExpr )
Solved! Go to Solution.
import arcpy jTable = "C:/Users/nwuenstel/Desktop/LocalP/Error_Process/Bangladesh_joinsV.csv" outTable = "in_memory\temptable" whereExpr = "\"UID\" = 'UID5'" arcpy.MakeTableView_management(jTable, outTable, whereExpr)
sCursor = arcpy.SearchCursor(table) for row in sCursor: if not row.Field: print "it's null" else: print "it's not null"
setNum = "5" env.workspace = "C:/Users/nwuenstel/Desktop/LocalP/Error_Process/Consolidated Shapes" outPath1 = "C:/Users/nwuenstel/Desktop/LocalP/Error_Process/om_shapes/poly0" arcpy.CopyFeatures_management("Bangladesh_Poly_Consolidated", outPath1 + setNum)
a search cursor is used with a for loop to return values for a field for each row
#Returns a feature layer composed of the features in 'parentFC' that #share the same "MY_ID" values as those in 'lookupTbl' lookupIds = [r.MY_ID for r in arcpy.SearchCursor(lookupTbl)] arcpy.MakeFeatureLayer_managment(parentFC, "lyr", "MY_ID in (" + str(lookupIds)[1:-1] + ")")
lookupIds = [r.MY_ID for r in arcpy.SearchCursor(lookupTbl) if r.MY_ID != None] arcpy.MakeFeatureLayer_managment(parentFC, "lyr", "MY_ID in (" + str(lookupIds)[1:-1] + ")")
for row in rows: row = rows.next() #<----- This is the problem.