fc = r"C:\temp\test.gdb\project" list = [] PR = "some text" for field in arcpy.ListFields(fc, "FID_GE41_REG_SBPD_MOB_"+PR+"_WOR_*"): list.append(field.name) arcpy.DeleteField_management(fc, list)
Hi Greg,You can use a wildcard in the ListFields function, and then pass the returned list to the DeleteField function. Ex:fc = r"C:\temp\test.gdb\project" list = [] PR = "some text" for field in arcpy.ListFields(fc, "FID_GE41_REG_SBPD_MOB_"+PR+"_WOR_*"): list.append(field.name) arcpy.DeleteField_management(fc, list)
You don't mention what error you are getting back.I assume you can drop the field if you hard code the field name?Have you tried printing out "FID_GE41_REG_SBPD_MOB_"+PR+"_WOR_9" , or comaparing it to the field name as returned by ListFields,to make sure it resolves as a match for your field name?Is PR (9) a string or int?
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.