<?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: How to use name an output using a variable from a list in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677660#M52503</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;do you variables have a path associated with them?&lt;/P&gt;&lt;P&gt;in otherwords is ECO actually c:/path/eco.shp &lt;/P&gt;&lt;P&gt;because if you want to append "area" to that name, then you are going to have to parse out the *.shp part and add it back&lt;/P&gt;&lt;P&gt;ie temporarily parse off the shp part and add it back on.&amp;nbsp; This is the most explanatory form&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; ECO = "c:/mypath/eco.shp"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; ENEW = ECO[:-4]+"AREA"+".shp"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; ENEW&lt;/P&gt;&lt;P&gt;'c:/mypath/ecoAREA.shp'&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/clip.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/clip.htm"&gt;Clip—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Apr 2016 00:54:14 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-04-22T00:54:14Z</dc:date>
    <item>
      <title>How to use name an output using a variable from a list</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677659#M52502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use a for loop in arcpy, but am unsure of how to name the output using the variables from the list. I have attached a snippet of the code. Please let me know of any ideas. The list are all variables that are set to shapefiles. Please let me know if you have any ideas. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#for loop&lt;BR /&gt;x=[ECO, HPA, POT, NAV, OPA]&lt;/P&gt;&lt;P&gt;for i in x:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(i, "Pipeline_Buffer", i + "Areas")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Apr 2016 00:01:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677659#M52502</guid>
      <dc:creator>KellyZiegenfuss2</dc:creator>
      <dc:date>2016-04-22T00:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use name an output using a variable from a list</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677660#M52503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;do you variables have a path associated with them?&lt;/P&gt;&lt;P&gt;in otherwords is ECO actually c:/path/eco.shp &lt;/P&gt;&lt;P&gt;because if you want to append "area" to that name, then you are going to have to parse out the *.shp part and add it back&lt;/P&gt;&lt;P&gt;ie temporarily parse off the shp part and add it back on.&amp;nbsp; This is the most explanatory form&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; ECO = "c:/mypath/eco.shp"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; ENEW = ECO[:-4]+"AREA"+".shp"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; ENEW&lt;/P&gt;&lt;P&gt;'c:/mypath/ecoAREA.shp'&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/clip.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/clip.htm"&gt;Clip—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Apr 2016 00:54:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677660#M52503</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-22T00:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use name an output using a variable from a list</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677661#M52504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or (more slicing and dicing...)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; p = "c:/myPath/myShape.shp"
&amp;gt;&amp;gt;&amp;gt; p
'c:/myPath/myShape.shp'
&amp;gt;&amp;gt;&amp;gt; pNew = "{}{}{}".format(p.split(".")[0], "Area.", p.split(".")[1])
&amp;gt;&amp;gt;&amp;gt; pNew
'c:/myPath/myShapeArea.shp'
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:34:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677661#M52504</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-12T04:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use name an output using a variable from a list</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677662#M52505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, but fancy formatting is not intro level as is slicing.&amp;nbsp; But it is elegant ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; ECO = "c:\mypath\eco.shp"
&amp;gt;&amp;gt;&amp;gt; "{}{}{}".format(ECO[:-4],"Area",ECO[-4:])
'c:\\mypath\\ecoArea.shp
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/55581" target="_blank"&gt;Fancy, fancy formatting&lt;/A&gt;&amp;nbsp; for the explorer&lt;/P&gt;&lt;P&gt;and ensures the correct path format&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:34:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-name-an-output-using-a-variable-from-a/m-p/677662#M52505</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T04:34:14Z</dc:date>
    </item>
  </channel>
</rss>

