No Maps or Layers returned by arcpy.da.Walk()

1079
5
05-29-2013 02:11 AM
EssamElhalhuli
New Contributor
I have been trying to implement arcpy.da.Walk() as a replacement for the os.walk when looking for spatial data.
My code is very simple:

with open(output, 'wb') as csvfile:
    csvwriter = csv.writer(csvfile)
    for dirpath, dirnames, filenames in arcpy.da.Walk(workspace,followlinks = True):
        for filename in filenames:
            desc = arcpy.Describe(os.path.join(dirpath, filename))
            csvwriter.writerow([desc.catalogPath, desc.name, desc.dataType])

The output contains most items (e.g. tables, geodatabases, feature classes) but does not contain .mxd, .lyr and .mpk files.
When I checked the documentation, this function should pick up these files. I have tested it on several paths and still cannot get these items in my output.
Tags (2)
0 Kudos
5 Replies
RhettZufelt
MVP Frequent Contributor
Curious as to what documentation you looked at.  I looked here http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000 and don't even see the mention of mxd, lyr, or mpk anywhere on the page.

Looks to me like it is reporting exactly what it says it will.  Might have to grab the "missing" files with the old os.walk option.

R_
0 Kudos
EssamElhalhuli
New Contributor
In the list of data types on that page you have the below items:
�?�Any �??All data types are returned. Equivalent to using None or skipping the argument.
�?�CadDrawing �??�?�CadastralFabric �??�?�Container �??�?�FeatureClass �??�?�FeatureDataset �??�?�Geo �??�?�GeometricNetwork �??�?�LasDataset �??�?�Layer �??�?�Locator �??�?�Map �??�?�MosaicDataset �??�?�PlanarGraph �??�?�RasterBand �??�?�RasterCatalog �??�?�RasterDataset �??�?�RelationshipClass �??�?�RepresentationClass �??�?�SchematicDataset �??�?�Style �??�?�Table �??�?�Terrain �??�?�Text �??�?�Tin �??�?�Tool �??�?�Toolbox �??�?�Topology �??
0 Kudos
RhettZufelt
MVP Frequent Contributor
Guess I'm used to seeing Layer as a reference to the layer object (can be pointed to inside a layer file (just a pointer)), so not sure if that is supposed to list .lyr files, or just layers themselves (as when running in ArcMap).  As far as Map, I don't see any definition/explanation about what that is supposed to be.  Everywhere else in the docs, the refer to a map document/mxd.  Seems like they need to include some definitions in the documentation to clarify.  they give valid raster types and valid feature types, why not valid all types??

So if they are actually referring to *.lyr and *.mxd files as a datatype rather than a pointer file, then you are correct, they do not report these.  I guess in any case you are correct, as these types of files appear to be ignored by da.walk.  In any case, it seems like an oversight.  If it reports .dwg, .shp, .txt, .jpg, .etc., one would think it would easily report .lyr and .mxd as well.

R_
0 Kudos
JasonScheirer
Occasional Contributor III
Map and Layer refer to Map and Layer objects, not files. Since Walk does not go into MXD files at 10.1, these filters aren't particularly useful.
0 Kudos
RhettZufelt
MVP Frequent Contributor
If walk doesn't go into mxd's, then wouldn't they particularly useless?

Would be nice if they removed the "auto filter" that blocks the .lyr, .mxd, etc files.  Should be able to report it as well as other .extention files.

I posted an enhancement on the ideas page, you may want to promote it.

https://c.na9.visual.force.com/apex/ideaView?id=087E00000004eZ1&returnUrl=%2Fapex%2FideaList%3Fc%3D0...

R_