I have a SDE feature data set with certain feature class I need to delete. I need to be able to delete them by name, because there are other feature class in there that I do not need to delete.
I have the following, it runs but it doesn't delete anything. I get no error either.
I am using this in a Calculate Value model.
Expression
FEMA1()
Code block
import arcpy, os
def FEMA1():
arcpy.env.workspace = r"C:/Users/***/AppData/Roaming/Esri/ArcGISPro/Favorites/***.sde/CCDS.CCDS.TempLyrs"
cws = arcpy.env.workspace
fc_Delete = ["CCDS.CCDS.FEMA_FLOOD_ZONES_Temp","CCDS.CCDS.FLOODWAY_Temp","CCDS.CCDS.LOMAs_Temp","CCDS.CCDS.LOMRs_Temp","CCDS.CCDS.FEMA_Cross_Sections_Temp","CCDS.CCDS.FEMA_Base_Flood_Elevations_Temp", "CCDS.CCDS.FEMA_PANELS_Temp"]
for fc in fc_Delete:
fc_path = os.path.join(cws, fc)
if arcpy.Exists(fc_path):
arcpy.Delete_management(fc_path)
else:
return ("Feature classes do not exist")