Skip to content

Instantly share code, notes, and snippets.

@gispd
gispd / get_workspace_path.py
Last active August 29, 2015 14:11
A function to get a Geodatabase path from the feature class or table
def get_geodatabase_path(input_table):
'''Return the Geodatabase path from the input table or feature class.
:param input_table: path to the input table or feature class
'''
workspace = os.path.dirname(input_table)
if [any(ext) for ext in ('.gdb', '.mdb', '.sde') if ext in os.path.splitext(workspace)]:
return workspace
else:
return os.path.dirname(workspace)