I have numerous shapefiles with two fields, "ID2" (Integer) and "FILENAME" (String). Using arcpy I'm trying to query the attribute table for rows that have a certain value ("SCN_TCV_001_2002") in FILENAME and for those rows find the max value of the ID2 field. I think I'm just missing something in the query syntax. My code is below which returns an error at the last line "AttributeError: 'NoneType' object has no attribute 'getValue'". I'm using ArcGIS 10.2.2 with an Advanced License.
import arcpy, os, sys from arcpy import env env.workspace = "C:\\folder1" fclist = arcpy.ListFeatureClasses() for fc in fclist: field1 = 'FILENAME' field2 = 'ID2' sWhereClause = '"' + field1 + '"' + ' = ' + "'" + "SCN_TCV_001_2002" + "'" maxValue = arcpy.da.SearchCursor(fc, sWhereClause, "", "", field2 + " D").next().getValue(field2)