Using da.Walk to discover feature datasets throughout a series of subfolders

4971
13
09-29-2016 06:31 AM
EricEagle
Occasional Contributor III

Hi, so here's what I'm trying to do.  I have a parent folder, which I'm calling my workspace.  Under that folder are several subfolders, each containing one file geodatabase.  Each file geodatabase contains unique feature datasets that I'm trying to merge into one final file geodatabase.

I'm stuck at building the list of the feature datasets.  Here's the code in question:

folder = "C:\\Temp\\Extracted"

walk = arcpy.da.Walk(folder, datatype="FeatureDataset")
    for dirpath, workspaces, datatypes in walk:
        for datatype in datatypes:
            print(datatype)

This code yields *everything* in the subdirectory structure down to the feature dataset level.  It lists all folder names, all file geodatabases at the .gdb level, and all feature datasets.

What I'm trying to do is get a list back of *only* feature datasets.  Can someone tell me where I'm going wrong?

Tags (2)
0 Kudos
13 Replies
JoshuaBixby
MVP Esteemed Contributor

You think they will migrate ArcMap to Python 3.x?  You are a more hopeful man than I.

0 Kudos
DanPatterson_Retired
MVP Emeritus

yes.  I don't know why they didn't do it for 10.4... but having said that, you just need to install PRO and you can work in both worlds.

/blogs/dan_patterson/2016/04/12/coming-to-python-preparation-and-anticipation 

/blogs/dan_patterson/2016/07/17/anaconda-spyder-and-arcgis-pro 

and if you have an iPhone, iPad or any iThingy..... /blogs/dan_patterson/2016/06/17/python-35-comes-to-ithings 

0 Kudos
ChristianWells
Esri Regular Contributor

Here is the steps on adding code blocks to GeoNet:

https://community.esri.com/people/huffmanp/blog/2014/07/08/how-do-we-add-code-blocks-in-this-new-for... 

To add to bixb0012‌ comments, can you post the output of your script, perhaps in a txt file?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Christian as well /blogs/dan_patterson/2016/08/14/script-formatting beyond the basic stuff as well

0 Kudos