rows = arcpy.da.SearchCursor(someFC,someFields,someQuery) print (len(rows)) #I'm sure this used to work with the old cursors, but doesn't work with da.SearchCursor
Solved! Go to Solution.
arcpy.SelectLayerByAttribute_management("fl1", "NEW_SELECTION", "LAND_COVER_CD in (41,42)")
result = len([r for r in arcpy.da.SearchCursor("fl1", ["OID@"])])
#Or this if you don't need an actual "selected set"...
result = len([r for r in arcpy.da.SearchCursor(fc, ["OID@"], "LAND_COVER_CD in (41,42)")])
I'd suggest you to encapsulate it into a function. I developed a tiny function called SearchCounter derivated from a Validator in a previous blog post.
counts = 0
for counter in cursor:
counts += 1;
RecordCount = SearchCounter(arcpy.da.SearchCursor(Table,Fields,Query))