ArcPy DIR function for geodatabases

06-03-2019 07:20 AM
New Contributor II

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
0 Kudos
1 Reply
MVP Frequent Contributor

A much better place to share your code is on the ESRI code sharing website. That is the place for developers and members of the user community to share tools and code and would be an obvious place to start searching. It is unlikely people would come to a discussion forum in search of specific code... Personally I would move it to there and delete this thread.

But don't just dump it there, you need to describe it, explain any limitations, how you would run it and for what version of ArcMap if you want people to truly find it useful.

0 Kudos