Here is an example on how to do this. The code uses the Summary Statistics tool to summarize the Area field in each polygon feature class within feature datasets, then writes the feature class name and Area sum to a previously created table.import arcpy
from arcpy import env
env.overwriteOutput = True
env.workspace = r"C:\MapsandGeodatabase\LocalGovernment.gdb"
arcpy.CreateTable_management(env.workspace, "AREA_SUM")
arcpy.AddField_management("AREA_SUM", "Name", "Text", "75")
arcpy.AddField_management("AREA_SUM", "SUM_Shape_Area", "Double")
for dataset in arcpy.ListDatasets("*"):
lstFCs = arcpy.ListFeatureClasses("*", "", dataset)
for fc in lstFCs:
desc = arcpy.Describe(fc)
if desc.shapeType == "Polygon":
rows = arcpy.InsertCursor("AREA_SUM")
row = rows.newRow()
row.Name = fc
sumArea = arcpy.Statistics_analysis(fc, "Stats", [["Shape_Area", "SUM"]])
rows2 = arcpy.SearchCursor(sumArea)
for row2 in rows2:
totArea = row2.getValue("SUM_Shape_Area")
row.SUM_Shape_Area = totArea
rows.insertRow(row)
totArea = 0
del row, rows, row2, rows2
arcpy.Delete_management("Stats")