My model is to upload an xy table, define, and project it, while using the worksheet name as the final name of the projected data. This works great. When I add a clip function, so points are clipped to a study area, the $ that arc adds to the table name is an invalid character.
Using calculate value to strip the $, I get a 1, not the string minus the $. So output file is "1_clip.shp", rather than the "wksheet name_clip.shp". When Calc Value is in model, the output is listed as a greyed out 1. Seems odd, like the expression isn't working? I've used several expressions and code blocks with the same results. The upload, project and clip works smoothly, just gives it the wrong file name. Any ideas? (In case you can't tell, I'm not a strong python person, yet)
Projected_and_Clipped_Data = arcpy.GetParameterAsText(5) if Projected_and_Clipped_Data == '#' or not Projected_and_Clipped_Data: Projected_and_Clipped_Data = "X:\\Tools\\XY\\point_upload\\Data\\%fixed%_Clip.shp" # provide a default value if unspecified
# Local variables: xy_event = XY_Table v_defined = xy_event defined_data = v_defined v_projected = defined_data Value = XY_Table
There're some options: 1. In Excel, select desired cells range and give it a unique name (you can specify range name in area left to functions button). Then in ArcGIS you would have this name displayed without $.
2. In Calculate Value model-only tool try this: Expression: removeChar("%Value%") Code Block:
def removeChar(val): if val.endswith("$"): return val[:-1]
or
def removeChar(val): return val.split("$")[0]
and use output inline variable from this tool to name resulting feature classes.
There're some options: 1. In Excel, select desired cells range and give it a unique name (you can specify range name in area left to functions button). Then in ArcGIS you would have this name displayed without $.
2. In Calculate Value model-only tool try this: Expression: removeChar("%Value%") Code Block:
def removeChar(val): if val.endswith("$"): return val[:-1]
or
def removeChar(val): return val.split("$")[0]
and use output inline variable from this tool to name resulting feature classes.