Select to view content in your preferred language

Newbie - trying to do something simple with arcpy.da.walk

1512
3
Jump to solution
08-20-2021 11:11 AM
PeterWang
Occasional Contributor

I just want to walk down a file system and print out what GIS data are present; nothing fancy for right now.

import arcpy

import os 

workspace=R"C:\Users\MeMyself\Data"

walk = arcpy.da.Walk(workspace)

Print(walk) 

but this doesn't work to print out this tuple... I get <Workspace Walker object object at 0x000001FF12CC7F00>

So the tuple "walk" exists... I can do a Type(walk) on it, type is <class 'Workspace Walker object'> but how do I print it out so I can read it?

Thanks.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

Walk—ArcGIS Pro | Documentation

has code examples


... sort of retired...

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

Walk—ArcGIS Pro | Documentation

has code examples


... sort of retired...
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If you want to see the first tuple (it is common to have more than one tuple):

print(next(walk))  
0 Kudos
JoeBorgione
MVP Emeritus

Take a closer look at the online help page.  Like other arcpy tools, this one creates an Object, and you have to tease the properties out of that object to make sense of it.  The help page gives a good example of mixing arcpy along with the os module in python to get what you are after. 

That should just about do it....