import arcgisscripting gp = arcgisscripting.create(9.3) table = "C:\GISDATA\resultTable" fields = gp.ListFields(resultTable) for field in fields: if ((field.name != "BUILD_ID") and (field.name != "MAX")): gp.deletefield(table, field)
I think you will also then need to pass that to the list fields
fields = gp.ListFields(table)
instead of
fields = gp.ListFields(resultTable)
note: if that table is a shapefile attempting to delete a required field (e.g., FID) should also fail.
Well after 6 years I doubt he care... and just incase anyone forgets to use raw string formatting when using python, here is what happens
>>> table = "C:\GISDATA\resultTable" >>> print(table) esultTable
No wonder the table couldn't be found