<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculate Value gives 1, not string in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/calculate-value-gives-1-not-string/m-p/302364#M10514</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Model was solved using the expressions given above, and the model given here &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/68337-Parse-Path-or-Calculate-Value"&gt;http://forums.arcgis.com/threads/68337-Parse-Path-or-Calculate-Value&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Oct 2012 13:56:45 GMT</pubDate>
    <dc:creator>MikeBarrett</dc:creator>
    <dc:date>2012-10-10T13:56:45Z</dc:date>
    <item>
      <title>Calculate Value gives 1, not string</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-value-gives-1-not-string/m-p/302362#M10512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Import arcpy module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Load required toolboxes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.ImportToolbox("Model Functions")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set Geoprocessing environments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.scratchWorkspace = "X:\\Tools\\XY\\point_upload\\Scratch"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "X:\\Tools\\XY\\point_upload\\Data"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Script arguments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;XY_Table = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Define_Coordinate_System = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Projection = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Geographic_Transformation = arcpy.GetParameterAsText(3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Study_Area = arcpy.GetParameterAsText(4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Projected_and_Clipped_Data = arcpy.GetParameterAsText(5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if Projected_and_Clipped_Data == '#' or not Projected_and_Clipped_Data:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Projected_and_Clipped_Data = "X:\\Tools\\XY\\point_upload\\Data\\%fixed%_Clip.shp" # provide a default value if unspecified&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Local variables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;xy_event = XY_Table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;v_defined = xy_event&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;defined_data = v_defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;v_projected = defined_data&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Value = XY_Table&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Parse Path&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.ParsePath_mb(XY_Table, "NAME")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Make XY Event Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempEnvironment0 = gp.scratchWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.scratchWorkspace = "X:\\Tools\\XY\\point_upload\\Scratch"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempEnvironment1 = gp.workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "X:\\Tools\\XY\\point_upload\\Data"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeXYEventLayer_management(XY_Table, "", "", xy_event, "", "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.scratchWorkspace = tempEnvironment0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = tempEnvironment1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Copy Features&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempEnvironment0 = gp.scratchWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.scratchWorkspace = "X:\\Tools\\XY\\point_upload\\Scratch"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(xy_event, v_defined, "", "0", "0", "0")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.scratchWorkspace = tempEnvironment0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Define Projection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.DefineProjection_management(v_defined, Define_Coordinate_System)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Project&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempEnvironment0 = gp.scratchWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.scratchWorkspace = "X:\\Tools\\XY\\point_upload\\Scratch"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempEnvironment1 = gp.workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "X:\\Tools\\XY\\point_upload\\Data"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Project_management(defined_data, v_projected, Projection, Geographic_Transformation, "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.scratchWorkspace = tempEnvironment0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = tempEnvironment1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Clip&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Clip_analysis(v_projected, Study_Area, Projected_and_Clipped_Data, "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Calculate Value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateValue_management("\"%Value%\".strip(\"$\")", "\\n", "String")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 14:26:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-value-gives-1-not-string/m-p/302362#M10512</guid>
      <dc:creator>MikeBarrett</dc:creator>
      <dc:date>2012-10-08T14:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Value gives 1, not string</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-value-gives-1-not-string/m-p/302363#M10513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There're some options:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. In Excel, select desired cells range and give it a unique name (you can specify range name in area left to functions button).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then in ArcGIS you would have this name displayed without $.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. In Calculate Value model-only tool try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;removeChar("%Value%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def removeChar(val): &amp;nbsp; if val.endswith("$"): &amp;nbsp;&amp;nbsp;&amp;nbsp; return val[:-1]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def removeChar(val): &amp;nbsp; return val.split("$")[0]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;and use output inline variable from this tool to name resulting feature classes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 07:43:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-value-gives-1-not-string/m-p/302363#M10513</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2012-10-09T07:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Value gives 1, not string</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-value-gives-1-not-string/m-p/302364#M10514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Model was solved using the expressions given above, and the model given here &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/68337-Parse-Path-or-Calculate-Value"&gt;http://forums.arcgis.com/threads/68337-Parse-Path-or-Calculate-Value&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 13:56:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-value-gives-1-not-string/m-p/302364#M10514</guid>
      <dc:creator>MikeBarrett</dc:creator>
      <dc:date>2012-10-10T13:56:45Z</dc:date>
    </item>
  </channel>
</rss>

