Delete dbf fields

Discussion created by map.girl on Apr 1, 2013
Latest reply on Apr 2, 2013 by rdharles
I have a dbf table with four fields: OID,TYPE,FREQUENCY,COUNT.

I only want to keep TYPE. I got this script off this forum and modified it to fit my data but it is not working. Is that because it is a dbf file? It returns the correct fields for the "print field" command. Any other suggesestions?

test_dbf = "C:\\TempData\\testdata.dbf"

data_description = arcpy.Describe(test_dbf)
fields = [ for f in data_description.fields if f.type not in ["Geometry", "Raster", "Blob"]]

#fields = [ for f in arcpy.ListFields(test_dbf)  <> 'Geometry'] # This didn't work either
print fields

for i,f in enumerate(fields):
    if f == 'OID' or f == 'FREQUENCY' or f == 'COUNT':
        del fields[i]

Thank you in advance