Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy
- from arcpy import env
- env.workspace = "C:/data/Habitat_Analysis.gdb"
- arcpy.Statistics_analysis("FIELD_NAME", "C:/output/output.gdb/TABLE_OUTPUT", [["SUM"]])
- int_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "Integer")
- small_int_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "SmallInteger")
- double_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "Double")
- fields = int_fields + small_int_fields + double_fields
- # Import system modules
- import arcpy
- # Set environment settings
- env.workspace = "C:/data/Habitat_Analysis.gdb"
- # Set local variables
- intable = "FIELD_NAME"
- outtable = "C:/output/output.gdb/TABLE_OUTPUT"
- # casefield = "Name" Not used
- stats = []
- # Loop through all fields in the Input Table
- for field in arcpy.ListFields(intable):
- # Just find the fields that have a numeric type
- if field.type in ("Double", "Integer", "Single", "SmallInteger"):
- # Add the field name and Sum statistic type
- # to the list of fields to summarize
- stats.append([field.name, "Sum"])
- # Correct formatting of stats [["Field1", "Sum"], ["Field2", "Sum"], ...]
- # Run the Summary Statistics tool with the stats list
- arcpy.Statistics_analysis(intable, outtable, stats)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement