<?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 python code in modelbuilder using Calculate Value in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-code-in-modelbuilder-using-calculate-value/m-p/57685#M4556</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm attempting to check for the existence of a shapefile if it does not exist, an alternate dummy shapefile is returned in its place.&amp;nbsp; I'm using ArcGIS 10.1 Modelbuilder and specifically the Calculate Value tool, here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
chkSouceSHP(%YIP Delivery from York (Shapefile Folder):%\%YIPData_Name%.shp)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def chkSouceSHP(SourceSHP):
&amp;nbsp; if os.path.isfile(SourceSHP):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return SourceSHP
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "M:\GIS\Data\YIP\Process\BlankMetadata.shp"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Data Type:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Shapefile
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code errors out with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;ERROR 000539: SyntaxError: invalid syntax (&amp;lt;expression&amp;gt;, line 1)&lt;BR /&gt;Item not found in this collection.&lt;BR /&gt;Failed to execute (Calculate Value).&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or hints for where I can find help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've read: &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000v8000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000v8000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This error appears to be coming from Python, and since I'm quite new to it I'm hoping someone on here who has more experience will be able to figure this out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ontario, Canada&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:11:18 GMT</pubDate>
    <dc:creator>GregCzajko</dc:creator>
    <dc:date>2021-12-10T22:11:18Z</dc:date>
    <item>
      <title>python code in modelbuilder using Calculate Value</title>
      <link>https://community.esri.com/t5/python-questions/python-code-in-modelbuilder-using-calculate-value/m-p/57685#M4556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm attempting to check for the existence of a shapefile if it does not exist, an alternate dummy shapefile is returned in its place.&amp;nbsp; I'm using ArcGIS 10.1 Modelbuilder and specifically the Calculate Value tool, here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
chkSouceSHP(%YIP Delivery from York (Shapefile Folder):%\%YIPData_Name%.shp)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def chkSouceSHP(SourceSHP):
&amp;nbsp; if os.path.isfile(SourceSHP):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return SourceSHP
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "M:\GIS\Data\YIP\Process\BlankMetadata.shp"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Data Type:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Shapefile
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code errors out with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;ERROR 000539: SyntaxError: invalid syntax (&amp;lt;expression&amp;gt;, line 1)&lt;BR /&gt;Item not found in this collection.&lt;BR /&gt;Failed to execute (Calculate Value).&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or hints for where I can find help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've read: &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000v8000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000v8000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This error appears to be coming from Python, and since I'm quite new to it I'm hoping someone on here who has more experience will be able to figure this out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ontario, Canada&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:11:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-code-in-modelbuilder-using-calculate-value/m-p/57685#M4556</guid>
      <dc:creator>GregCzajko</dc:creator>
      <dc:date>2021-12-10T22:11:18Z</dc:date>
    </item>
  </channel>
</rss>

