Batch Sum Fields Script using ArcPy?

المشرف العام

Administrator
طاقم الإدارة
I have created a python script that batch summarizes all string fields within a fc table based on the concatenation of two fields. The script loops through a list of the fields, however it stops about halfway through (same spot each time). Why does this code not process the remaining string fields within the list? After running it once, if I delete all the fields that it processed correctly the first time, then run it again on only the fields that it did not process, it runs ok. Maybe my issue is with this line:

fieldname = flist.pop(0) Ideas?

See code below

import arcpy, os from arcpy import env try: # Local variables: inTable = arcpy.GetParameterAsText(0) outWKSpace = arcpy.GetParameterAsText(1) # Process: Add Field arcpy.AddField_management(inTable, "cat", "TEXT", "", "", "200", "", "NULLABLE", "NON_REQUIRED", "") flist = arcpy.ListFields(inTable, '', 'String') fieldname = '' for field in flist: fieldname = flist.pop(0) arcpy.CalculateField_management(inTable, "cat", "!Sub_Batch!+\" \"+ !"+ fieldname.name +"!", "PYTHON_9.3", "") outTable = outWKSpace + "\SUM_" + fieldname.name table2 = arcpy.Frequency_analysis(inTable, outTable, "cat", "") intCount = arcpy.GetCount_management(outWKSpace + "\SUM_" + fieldname.name) arcpy.AddMessage(fieldname.name + ' records = ' + str(intCount)) except Exception, e: import traceback map(arcpy.AddError, traceback.format_exc().split("\n")) arcpy.AddError(str(e))

أكثر...
 
أعلى