I wonder if someone can help me. I want to create a model that will iterate datasets within a FGDB and delete all where there is an empty output, or whether someone could help with an initial batch clip iteration where any empty outputs generated are deleted. I have tried many ways in model builder but can't get it to work.
The model below is what I have for the former
Solved! Go to Solution.
this might help?
import arcpy
workspace = "path/to/your/geodatabase.gdb"
arcpy.env.workspace = workspace
for fc in arcpy.ListFeatureClasses():
count = int(arcpy.GetCount_management(fc)[0])
if count == 0:
arcpy.Delete_management(fc)
print(f"Deleted empty feature class: {fc}")
this might help?
import arcpy
workspace = "path/to/your/geodatabase.gdb"
arcpy.env.workspace = workspace
for fc in arcpy.ListFeatureClasses():
count = int(arcpy.GetCount_management(fc)[0])
if count == 0:
arcpy.Delete_management(fc)
print(f"Deleted empty feature class: {fc}")
Amazing, thank you so much Ed!