<?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: Parse Path or Calculate Value? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286032#M9858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: j.quinn&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try to set the final output of the model to %Value%.shp, which will take advantage of using &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_using_inline_variable_substitution/002w0000001t000000/"&gt;inline variables&lt;/A&gt;&lt;SPAN&gt; to grab the value that's parsed from the Parse Path tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Oct 2012 17:14:34 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-10-04T17:14:34Z</dc:date>
    <item>
      <title>Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286031#M9857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am building a tool to simplify the uploading xy locations, defining and projecting, as I do this constantly. I???ve gotten that to work; upload the xy table, choose a GCS, then choose a projection. Currently, the projected file comes out as ???projected_data.shp???.&amp;nbsp; The ideal version of this would automatically name the projected output file with the name from the initial xy table. If the upload table were called ???Massachusetts sightings.xlsx???, the tool would take ???Massachusetts sightings??? and apply it to the output name, producing ???Massachusetts sightings.shp???. [ATTACH=CONFIG]18194[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can???t figure out if I need / want the parse path tool or Calculate value. I???ve read postings here, but can???t find out how to reconnect that ???Name??? field from parse path back to the Project output. (Although, I realize that with an xlsx file, we???re asked to provide which sheet data comes from, typically ???Sheet$??? or ???Sheet1???. Will parse path give this, or will it give the file name?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For Parse Path, I have [ATTACH=CONFIG]18196[/ATTACH] &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For Calculate Value, I have [ATTACH=CONFIG]18195[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I???ve been trying for a few days and can???t figure out how to reconnect the parse path output, or the calculate value output back into the model- notice they are not connected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideas? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks so much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 16:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286031#M9857</guid>
      <dc:creator>MikeBarrett</dc:creator>
      <dc:date>2012-10-04T16:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286032#M9858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: j.quinn&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try to set the final output of the model to %Value%.shp, which will take advantage of using &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_using_inline_variable_substitution/002w0000001t000000/"&gt;inline variables&lt;/A&gt;&lt;SPAN&gt; to grab the value that's parsed from the Parse Path tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 17:14:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286032#M9858</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-04T17:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286033#M9859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah! Simpler than I thought! Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For those following; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You simply write&amp;nbsp;&amp;nbsp;&amp;nbsp; %Value%&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (no quotes needed) into the output file name of the last tool to run (in this case Project), and Model Builder pulls the Value you've extracted by using the Parse Path Tool. (Value can be either the File, Name, Path, etc). You don't need to use Calculate Value, and you don't need a connecting line.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2012 15:29:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286033#M9859</guid>
      <dc:creator>MikeBarrett</dc:creator>
      <dc:date>2012-10-05T15:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286034#M9860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok- so when this model is updated to include a clip at the end, arc adds a $ to the worksheet name, which is an invalid character. Using calculate value to remove the $, i get a 1 instead of the worksheet name, after writing a variety of codes and expressions.&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:29:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286034#M9860</guid>
      <dc:creator>MikeBarrett</dc:creator>
      <dc:date>2012-10-08T14:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286035#M9861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: m.gasior&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Look at this answer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/68530-Calculate-Value-gives-1-not-string?p=239048&amp;amp;viewfull=1#post239048"&gt;http://forums.arcgis.com/threads/68530-Calculate-Value-gives-1-not-string?p=239048&amp;amp;viewfull=1#post239048&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 07:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286035#M9861</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-09T07:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286036#M9862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the help; however, I continue to get the same answer, no matter what code block / expression I use, the number 1. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've used the following expression / code blocks, all giving the following[ATTACH=CONFIG]18282[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;removeChar("%Value%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def removeChar(val):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if val.endswith("$"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return val[:-1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and/or &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def removeChar(val):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return val.split("$")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: "%Value%".strip("$")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;strip_chars("%Value%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os.path def strip_chars(s):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return os.path.basename(s).strip("$") &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;no matter what code I use, all I get is the 1 as my file name. Perhaps I'm using the inline variable wrong. If I use "%Value%".strip("$") as my expression, and then rename the green output circle as fixed, or as outputvalue, and then in the Clip tool, I write either %fixed%_clip, %Value%_clip, or %outputvalue%_clip, I get "1_clip.shp" as the output. I recieve a 1_clip no matter what combination of codes, expressions, etc I enter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm now remembering why I don't love arcpy...until it works, then we're best friends.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 14:08:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286036#M9862</guid>
      <dc:creator>MikeBarrett</dc:creator>
      <dc:date>2012-10-09T14:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286037#M9863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: m.gasior&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try the following approach:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In your model set Value inline variable as precondition to Calculate Value and output_value inline variable as precondition to Make XY Event Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This should enforce creating variables first before creating layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The model below works with some of the Python expressions mentioned earlier:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]18311[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 05:23:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286037#M9863</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-10T05:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Parse Path or Calculate Value?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286038#M9864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Perfect! I had been exploring moving the parse path/calculate value earlier in the model, but setting it at the very beginning works best. Thanks to all who supplied help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 13:54:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/parse-path-or-calculate-value/m-p/286038#M9864</guid>
      <dc:creator>MikeBarrett</dc:creator>
      <dc:date>2012-10-10T13:54:46Z</dc:date>
    </item>
  </channel>
</rss>

