AnsweredAssumed Answered

How to append summary statistics to dbf table

Question asked by Myla-Rae on Dec 20, 2017
Latest reply on Jan 2, 2018 by Myla-Rae

I am working on a project to characterize watersheds where we are carrying out fieldwork. I am trying to use Summary Statistics to sum all the stream length channels contained in a watershed for multiple feature classes (drainline).  Using arcpy.Statistics_analysis creates the output I want in a table but my script overwrites the table instead of adding the sum outputs to the table for each drainline feature. I am unable to figure out how to do this. My script on a subset of the data is below:

# Set local variables
ws_drainlines = arcpy.ListFeatureClasses("", "Line", "")
outStatsTable = "C:/_LOCALdata/AB_ARCHYDRO/AB_ARCHYDRO_NOP.GDB/DrainageDensity"
field = "Watershed"

# Sum the drainline lengths for each DrainLine feature
for drainline in ws_drainlines:
    arcpy.AddField_management(drainline, field, "TEXT", "", "", "20")
    arcpy.CalculateField_management(drainline, field, '"' + drainline + '"', "")
    arcpy.Statistics_analysis(drainline, outStatsTable, [["Shape_Length", "SUM"]], field)