Hi,
I am using Calculate Value in Model Builder in ArcGIS Pro 2.3 in order to truncate a feature class full name and keep only the feature class name.
The following piece of code do not work. It looks like Python is not parsing my inline variable because there is some backslash \ character...
where "fullPath" is the in-line variable I am passing in and the backslash \ is to truncate the feature class proper name to the rest of the path
Solved! Go to Solution.
I think you issue is you need to pass a raw string to preserve the path delimeter:
fn(r"%FullPath%")
BUT: I suggest using the Parse Path tool, or, if you still want to use Python, instead of string searches I recommend the functions in the os.path module: os.path.basename() and os.path.dirname().
I think you issue is you need to pass a raw string to preserve the path delimeter:
fn(r"%FullPath%")
BUT: I suggest using the Parse Path tool, or, if you still want to use Python, instead of string searches I recommend the functions in the os.path module: os.path.basename() and os.path.dirname().
Thanks. It is perfect!
The Parse Path tool help even gives syntax to work with os module directly in Python.
In ModelBuilder, the Parse Path tool is in the Uilities menu on the toolbar (and not in the toolbox) if anybody was looking for it.