AnsweredAssumed Answered

Looping problems! - Deleting fields

Question asked by matthewrusso on Feb 18, 2015
Latest reply on Feb 18, 2015 by matthewrusso

So I got my script to work but it is still giving me a problem.


When i run the script through command line it is printing out the elif clause about 10-15 times each before it starts to delete fields.  Anyone have any advice?


import arcpy

fieldList = ['ID','LAT','LON','AREA','PARIMETER','Hectares','CODE',
             'SEVERITY3','PATTERN1','PATTERN2','PATTERN3','TPA1', 'TPA2',
             'R201_DMG_I','AREA_METER', 'SOURCETHM','PCT_MORT1','PCT_MORT2',
arcpy.env.workspace = r'H:\GIS DATA\Data\Pine Beetle\Beetle\Test'
fcs = arcpy.ListFeatureClasses()

for fc in fcs:
    for i in fieldList:
        x = arcpy.ListFields(fc)
        for a in x:
            if i ==
                arcpy.DeleteField_management(fc, i)
                print i + ' was deleted from ' + fc
            elif i !=
                print i