david.round

ArcPy DIR function for geodatabases

Discussion created by david.round on Jun 3, 2019
Latest reply on Jun 6, 2019 by Hornbydd

I just wanted to share this function I built for listing the contents of a GDB in ArcPy. First it will print out a list of features in a given GDB, then it'll print out any tables. Simple but useful.

 

#lists contents of a GDB
def DIRgdb(gdbInput):
      arcpy.env.workspace = gdbInput
      print "\nfeatures:"
      featuresInGDB = arcpy.ListFeatureClasses()
      for feature in featuresInGDB:
            print "\t- " + feature
      tablesInGDB = arcpy.ListTables()
      print "\nTables:"
      for table in tablesInGDB:
            print "\t- " + table

Outcomes