I'm running a script that places all of the fields that I want to delete from a feature class into a list(ListName), but when I run the DeleteField_management I receive the error - Failed to execute. Parameters are not vaild. Invalid field type
import arcpy
import os
arcpy.env.workspace = "C:/Data_new/Temp/Default.gdb"
arcpy.env.overwriteOutput = True
parcel_clip2 = "C:/Data_new/Temp/Default.gdb/parcel_clip2"
fieldList = arcpy.ListFields(parcel_clip2)
ListName = []
fieldstokeep = ["Name1", "Address1", "City", "State", "ZipCode"]
for field in fieldList:
ListName.append(field.name)
index = 0
while index < len(ListName):
if ListName[index] in fieldstokeep:
ListName.remove(ListName[index])
else:
index = index + 1
print(ListName)
arcpy.DeleteField_management (parcel_clip2, ListName)
del ListName
del parcel_clip2
del fieldList
del fieldstokeep
I've been at this awhile and I don;t understand what the issue is. Any advice?Thanks!