Hello,
I have many feature classes in multiple gdbs that have empty feature classes. Is there anyway to automate a process to look through each .gdb, find the empty feature classes, and to delete the empty feature classes from the .gdb?
Thank you for your time all!
Regards,
Tom
Solved! Go to Solution.
There's a scroll bar on the bottom of the code area. It's all there!
If that is what you needed then please mark it as the answer. If not then mark Christian's answer as the solution since he posted it up first. It helps others find the answer if they search for the same thing.
Sorry about that, I am new to this environment. I am not returning anything on the code listed above. After running module, nothing is returned. Anything on this?
Post your code exactly as you have it written. We can't guess.
import arcpy
arcpy.env.workspace = "D:\test_script\clip.gdb"
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
result = arcpy.GetCount_management(fc)
count = int(result.getOutput(0))
if count == 0:
arcpy.Delete_management(fc)
Your workspace is incorrect or doesn't exist. Double-check that path/name/etct.. This will print "fcList is None!" if it doesn't find it:
import arcpy arcpy.env.workspace = "D:\test_script\clip.gdb" fcList = arcpy.ListFeatureClasses() if not fcList is None: for fc in fcList: result = arcpy.GetCount_management(fc) count = int(result.getOutput(0)) if count == 0: arcpy.Delete_management(fc) else: print "fcList is None!"
All works and all is fixed! Thank you for your time!
This is the best suggestion. Using ArcPy Walk is by far the most Pythonic approach to enumerating data sets.