Select to view content in your preferred language

List All Data in a Geodatabase using Arcpy?

14229
2
Jump to solution
10-16-2013 07:14 AM
MikeMacRae
Frequent Contributor
is there any possible way to list all contents in a geodatabase using arcpy? I have a geodatabase with feature classes and tables and I want to list them all in one for loop.

arcpy.ListFeatureCLasses()# only returns the feature classes

arcpy.ListTables() # only returns the tables 

arcpy.ListFiles() # returns all files in the workspace, not the binded feature classes or tables. 


Is there anything in the arcpy module that allows us to do this? I can't seem to find anything

Thanks,
Mike
Tags (2)
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
If you are 10.1 and above, you can look into the [url=http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000]arcpy.da.Walk[/url].

Otherwise, you can loop thru a gdb looking for feature datasets and set the arcpy.env.workspace to each Feature Dataset and list all Feature classes in each one.  You should be able to list all Tables and Rasters from the top of the gdb itself as these cannot be stored inside Feature Datasets.

View solution in original post

2 Replies
by Anonymous User
Not applicable
If you are 10.1 and above, you can look into the [url=http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000]arcpy.da.Walk[/url].

Otherwise, you can loop thru a gdb looking for feature datasets and set the arcpy.env.workspace to each Feature Dataset and list all Feature classes in each one.  You should be able to list all Tables and Rasters from the top of the gdb itself as these cannot be stored inside Feature Datasets.
MikeMacRae
Frequent Contributor
If you are 10.1 and above, you can look into the arcpy.da.Walk.

Otherwise, you can loop thru a gdb looking for feature datasets and set the arcpy.env.workspace to each Feature Dataset and list all Feature classes in each one.  You should be able to list all Tables and Rasters from the top of the gdb itself as these cannot be stored inside Feature Datasets.


Caleb. I just found an article discussing this. I am running 10.1 and I tested this. It works perfectly. Thanks for posting. The help file explains a little better than the article, but I like how they use the function in a defined function in the article:

http://arcpy.wordpress.com/tag/os-walk/