Created
March 1, 2018 16:09
-
-
Save mu88/4bc579c51d013e8ec429bdf5f8426be0 to your computer and use it in GitHub Desktop.
ArcPy - List all Object Classes of all File Geodatabases within a given directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy, codecs, csv, os, shutil | |
os.system("cls") | |
origFgdbLocation = r"\\Server\Share" | |
origFgdbNames = ["A", "B", "C"] | |
csvFilePath = r"C:\temp\members.csv" | |
elements = [] | |
for fgdbName in origFgdbNames: | |
print "Start FGDB '" + fgdbName + "'" | |
origFgdbPath = origFgdbLocation + os.path.sep + fgdbName + ".gdb" | |
arcpy.env.workspace = origFgdbPath | |
for fds in arcpy.ListDatasets(): | |
print "Start feature dataset '" + fds + "'" | |
arcpy.env.workspace = os.path.join(origFgdbPath, fds) | |
fcls = arcpy.ListFeatureClasses() | |
tables = arcpy.ListTables() | |
for fcl in fcls: | |
currentElement = [fgdbName, fds, fcl, "fcl"] | |
elements.append(currentElement) | |
for table in tables: | |
currentElement = [fgdbName, fds, table, "table"] | |
elements.append(currentElement) | |
arcpy.env.workspace = origFgdbPath | |
print "Finish feature dataset '" + fds + "'" | |
print "Start root feature classes" | |
arcpy.env.workspace = origFgdbPath | |
fcls = arcpy.ListFeatureClasses() | |
for fcl in fcls: | |
currentElement = [fgdbName, "", fcl, "fcl"] | |
elements.append(currentElement) | |
print "Finish root feature classes" | |
print "Start root tables" | |
tables = arcpy.ListTables() | |
for table in tables: | |
currentElement = [fgdbName, "", table, "table"] | |
elements.append(currentElement) | |
print "Finish root tables" | |
print "Finish FGDB '" + fgdbName + "'" | |
print "Finish all" | |
f = codecs.open(csvFilePath, "w", encoding="utf-8") | |
f.write("FGDB; Dataset; Element; Type\n") | |
for element in elements: | |
f.write(element[0] + "; " + element[1] + "; " + element[2] + "; " + element[3] + "\n") | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment