Select to view content in your preferred language

Print Each dataset in my geodatabase and then print each featureclass inside that

1138
2
07-01-2012 10:56 PM
AntonyPaul_M1
Deactivated User
Hi All,

I got a scenario like,

Print Each dataset in my geodatabase and then print each featureclass inside that.

I can print standalone feature classes but not able to print based on the Feature dataset level.

Could you please help me on this?

Cheers
Antony
Tags (2)
0 Kudos
2 Replies
MarcinGasior
Frequent Contributor
You can use ListDatasets("", "Features") function to list all feature datasets in geodatabase.
Example:
import arcpy

rootWorkspace = r"C:\tmp\Test.gdb"
arcpy.env.workspace = rootWorkspace

#list all feature datasets
featureDatasets = arcpy.ListDatasets("", "Feature")
for dataset in featureDatasets:

    #for each feature dataset change workspace and list feature classes it contains
    arcpy.env.workspace = rootWorkspace + "\\" + dataset
    print "Geodatabase dataset: " + dataset

    featureClasses = arcpy.ListFeatureClasses()
    for fc in featureClasses:
        print fc
0 Kudos
MichaelVolz
Esteemed Contributor
#for each feature dataset change workspace and list feature classes it contains
    arcpy.env.workspace = rootWorkspace + "\\" + dataset

Is the above line critical to get the script to acknowledge the 2nd dataset?

I am just setting the arcpy.env.workspace = dataset and it only works on the first dataset in a file geodatabase.
0 Kudos