<?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: If-then-else using Calculate Value in a Geoprocessing Service in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/if-then-else-using-calculate-value-in-a/m-p/94902#M3272</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Curtis for your reply, but changing to python built-ins False or True did not allow the GP service to run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any other ideas??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Jul 2011 11:18:45 GMT</pubDate>
    <dc:creator>HeatherLizama</dc:creator>
    <dc:date>2011-07-25T11:18:45Z</dc:date>
    <item>
      <title>If-then-else using Calculate Value in a Geoprocessing Service</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/if-then-else-using-calculate-value-in-a/m-p/94900#M3270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please help me find out why and how to fix a Geoprocessing model (v10)? The current model calculates census data and needs to have an if-then-else using the Calculate Value tool. The code below is working wonderfully on desktop, but crashes in a service with the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error 000539: Error running expression: x(r"c:\arcgisserver\arcgisjobs\Population_tools\model3_gpserver\jb18558850e7e47799a\scratch\scratch.gdb\Census_join") &amp;lt;type 'exceptions.ImportError'&amp;gt;: No module named collections&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python code within Calculate Value in Geoprocessing Service:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# First Calculate Value should count the number of rows in the feature class and continue with&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# the calculations if it is = 1 row.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x(r"%Census_join%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def x(InputFeatureClass):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;result = arcpy.GetCount_management(InputFeatureClass)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if int(result.getOutput(0)) == 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return "true"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return "false"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Second Calculate Value should count the number of rows in the feature class and continue with&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# the calculations if there is &amp;gt; 1 row.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x(r"%Census_join%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def x(InputFeatureClass):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;result = arcpy.GetCount_management(InputFeatureClass)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if int(result.getOutput(0)) == 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return "false"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return "true"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Data type: Boolean&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help to make this work as a service...would be hugely helpful!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jul 2011 17:17:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/if-then-else-using-calculate-value-in-a/m-p/94900#M3270</guid>
      <dc:creator>HeatherLizama</dc:creator>
      <dc:date>2011-07-22T17:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: If-then-else using Calculate Value in a Geoprocessing Service</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/if-then-else-using-calculate-value-in-a/m-p/94901#M3271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know if this will help with your problem, but the strings "false" and "true" are both true:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; bool("true")
True
&amp;gt;&amp;gt;&amp;gt; bool("false")
True
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You probably want to return python built-ins False or True:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;return True&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:37:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/if-then-else-using-calculate-value-in-a/m-p/94901#M3271</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-10T23:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: If-then-else using Calculate Value in a Geoprocessing Service</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/if-then-else-using-calculate-value-in-a/m-p/94902#M3272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Curtis for your reply, but changing to python built-ins False or True did not allow the GP service to run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any other ideas??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 11:18:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/if-then-else-using-calculate-value-in-a/m-p/94902#M3272</guid>
      <dc:creator>HeatherLizama</dc:creator>
      <dc:date>2011-07-25T11:18:45Z</dc:date>
    </item>
  </channel>
</rss>

