Are you asking about a way to walk through a directory and find gdb's? One way:
import arcpy, os
from arcpy import env
workspace = r"C:\Path\to\explore"
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype="Container"):
for dirname in dirnames:
if ".gdb" in dirname:
env.workspace = os.path.join(dirpath, dirname)
# print env.workspace
tableList = arcpy.ListFeatureClasses()
# print tableList
for table in tableList:
# print
print "{}\t{}\t{}".format(dirpath, dirname, table)
Are you asking about a way to walk through a directory and find gdb's? One way:
import arcpy, os
from arcpy import env
workspace = r"C:\Path\to\explore"
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype="Container"):
for dirname in dirnames:
if ".gdb" in dirname:
env.workspace = os.path.join(dirpath, dirname)
# print env.workspace
tableList = arcpy.ListFeatureClasses()
# print tableList
for table in tableList:
# print
print "{}\t{}\t{}".format(dirpath, dirname, table)
Randy,
I have a similar issue I need help with if you don't mind. I have a few .xlsx files in a folder location (name example: Bermuda Rd MP 0_26 102017_TestTable.xlsx) and I would like to list the files and then split their names up to use as a query to update data in a ArcOnline feature service. The first part of the file name would be for the RoadName attribute (ex. Bermuda Rd) and the second part of the file name is the Milepost location (ex. 0_26) and the underscore in the file name would need to be replaced with a "." to match the ArcOnline Milepost attribute. How would I list the file names, split the text up and then use those as variables to build my query upon?
Thanks,
Anthony
with arcpy.walk there are a variety of other parameters that might be worth a read since they are specific to Arc* and do 'stuff' that the os equivalent can't do