AnsweredAssumed Answered

an example of how not to use a cursor

Question asked by nwuenstel on Nov 14, 2012
Latest reply on Nov 15, 2012 by lpinner
I have written a script to loop through all rows in a specified field in a table and 'add to selection' all the features that match. If i run the lines individually, outside of the for loop then it works. When I run it in the loop it runs through about 90 and then gives the error:

'NoneType' object has no attribute 'getValue error

I have seen this topic in several other forum posts but none with a resolution. Any suggestions?

Thanks...

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 ) 

Outcomes