Created
January 17, 2018 21:29
-
-
Save maphew/35c4e74b2b547943196229e5f807ec30 to your computer and use it in GitHub Desktop.
partial helper for reliably deriving workspace path from input Feature Class path
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
def parse_path(fc_path): | |
'''Derive workspace from Feature Class's location | |
Adapted from http://pro.arcgis.com/en/pro-app/tool-reference/modelbuilder-toolbox/parse-path.htm''' | |
fc = os.path.basename(fc_path) | |
dir = os.path.dirname(fc_path) | |
name = os.path.basename(fc_path).rstrip(os.path.splitext(fc_path)[1]) | |
ext = os.path.splitext(fc_path)[1].lstrip(".") | |
if ext.lower() == 'gdb': | |
workspace = fc_path | |
else: | |
workspace = dir | |
return [workspace, dir, fc, name, ext] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment