import arcpy from arcpy import env # Sets the workspace env.workspace = "L:\TEMP\test_Database_working.gdb" # lists all feature classes in the workspace (geodatabase) listFCs = arcpy.ListFeatureClasses("*") # lists all feature datasets in the workspace (geodatabase) listFDs = arcpy.ListDatasets("*") # loops through the Feature Class list and deletes any with 0 features for fc in listFCs: count1 = str(arcpy.GetCount_management(fc)) if count1 == "0": arcpy.Delete_management(fc) # loops through the Feature Dataset list and deletes any with 0 feature classes # this part contains errors but shows what I'm attempting to acheive for dataset in listFDs: count2 = str(arcpy.GetCount_management(dataset)) if count2 == "0": arcpy.Delete_management(dataset)
import arcpy from arcpy import env # Sets the workspace env.workspace = r"L:\TEMP\test_Database_working.gdb" # lists all feature classes in the workspace (geodatabase) listFCs = arcpy.ListFeatureClasses("*") # lists all feature datasets in the workspace (geodatabase) listFDs = arcpy.ListDatasets("*") # loops through the Feature Class list and deletes any with 0 features for fc in listFCs: count1 = str(arcpy.GetCount_management(fc)) if count1 == "0": arcpy.Delete_management(fc) # loops through the Feature Dataset list and deletes any with 0 feature classes # this part contains errors but shows what I'm attempting to acheive for dataset in listFDs: count = 0 for fc in arcpy.ListFeatureClasses("*", "", dataset): count2 = str(arcpy.GetCount_management(fc)) if count2 == "0": arcpy.Delete_management(fc) else: count +=1 if count == 0: print "Delete dataset: " + dataset arcpy.Delete_management(dataset) print "End process"
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.