I am trying to calculate summary statistics for a number of shapefiles, which is easy enough, but the field name for each shapefile is different. The field name is identical to the file name if that makes things easier.
I'm trying to use the following script:
import arcpy, os from arcpy.sa import * arcpy.env.workspace = r'C:\Users\kellyj\Desktop\Projects\CostAnalysis\SHP' for file in arcpy.ListFiles("*.shp"): arcpy.env.overwriteOutput = 1 filename = file[0:-4] print "Calculating " + filename arcpy.Statistics_analysis(file, arcpy.env.workspace + "/" + filename, [[filename, "SUM"]], "") print "Done"
How can I write this script so that I can use the file name as the statistics field?