Dear Friends,
Please find the attached gdb. How to delete the empty feature class from gdb.
Thanks
Santhosh
Solved! Go to Solution.
Santhosh,
You can manually right click on the tables in ArcCatalog and select "delete". You could also write a python script to loop through each feature class, and where total count = 0, run the tool that Dan suggested.
Something like:
import arcpy
from arcpy import env
env.workspace = 'D:/YourPathHere/Power.mdb'
data_sets = arcpy.ListDatasets()
for item in data_sets:
fcList = arcpy.ListFeatureClasses('', '', item)
for item in fcList:
fcLength = arcpy.GetCount_management(item)
if int(fcLength.getOutput(0)) == 0:
arcpy.Delete_management(item)
the Delete tool pretty well covers how to delete a featureclass... with a series of "can't do". You will have to elaborate why you can't delete one (ps, see the code example
Santhosh,
You can manually right click on the tables in ArcCatalog and select "delete". You could also write a python script to loop through each feature class, and where total count = 0, run the tool that Dan suggested.
Something like:
import arcpy
from arcpy import env
env.workspace = 'D:/YourPathHere/Power.mdb'
data_sets = arcpy.ListDatasets()
for item in data_sets:
fcList = arcpy.ListFeatureClasses('', '', item)
for item in fcList:
fcLength = arcpy.GetCount_management(item)
if int(fcLength.getOutput(0)) == 0:
arcpy.Delete_management(item)
YourPathHere was changed in your real script, wasn't it? and does it exist
Do add to Dan's question, please post the specific code generating the error and the whole error message.
Santhosh,
If you are running my snippet from above (looks like you are from your error message attached)...your syntax is incorrect based on improper spacing.
I copied my snippet directly into idle and did not have an issue, but it looks like something got out of alignment in your error.
Please make sure your indentation is correct:
10 Common Python Errors of Beginning ArcGIS Programmers |
Make sure your Power.mdb is actually located here "E:\YourPathHere\Power.mdb." You could have updated this path to something else, I was literally saying "Your path on your computer to your access database here." You created a new path instead of updating the line within the code.
~Alex