Each feature dataset is considered its own environment by arcpy, so functions like Walk() and ListFeatureClasses() will ignore stuff in a feature dataset if run on a geodatabase.
What you have to do instead is iterate through what's returned by Walk, check if it's a featuredataset, then change the environment to the featuredataset and list those feature classes in it.
Here's some sample code I wrote. In this case, "fd" was originally the output of arcpy.ListFeatureDatasets(), but you could sub in the files from Walk()
dirP = #whatever gdb you were running Walk() on
desc= (arcpy.da.Describe(fd))
if 'datasetType' in desc:
if desc['datasetType'] == "FeatureDataset":
arcpy.env.workspace = os.path.join(dirP, fd)
fdFCList = arcpy.ListFeatureClasses()
if fdFCList:
for fc in fdFCList:
fList.append([os.path.join(
desc['catalogPath'],fc)])
# Reset the workspace or else this breaks.
arcpy.env.workspace = dirP
@AlfredBaldenweck wrote:Each feature dataset is considered its own environment by arcpy, so functions like Walk() and ListFeatureClasses() will ignore stuff in a feature dataset if run on a geodatabase.
Not quite right for Walk. You just need to keep iterating through the Walk results. Any feature datasets are considered workspaces, so Walk will recurse to them and return their contents.
Good to know, thanks for the clarification.
I avoid Walk because it doesn't do quite what I want it to do.
Works for me in ArcMap 10.8.2. Given a FGDB with 2 FCs, "A" and "B" with "B" in feature dataset "FD":
import arcpy
for parent, workspaces, datasets in arcpy.da.Walk("Default.gdb"):
print("parent: %s"%parent)
print("workspaces: %s"%workspaces)
print("datasets: %s"%datasets)
Output showing that "B" is listed correctly in the feature dataset "FD":
parent: Default.gdb
workspaces: [u'FD']
datasets: [u'A']
parent: Default.gdb\FD
workspaces: []
datasets: [u'B']