<?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 statement won't bypass zeros in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675246#M52251</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dan Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What I have been reading suggests an If statement can be singular without an else statement. Perhaps your experience is otherwise. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RT&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Nov 2011 20:52:18 GMT</pubDate>
    <dc:creator>RichardThurau</dc:creator>
    <dc:date>2011-11-23T20:52:18Z</dc:date>
    <item>
      <title>If statement won't bypass zeros</title>
      <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675242#M52247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Trying to calculate fields using some division. Of course, division by zero is bad. Created what I thought was a simple if statement to skip zeros:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;rows2 = arcpy.SearchCursor(parcels)
for row2 in rows2:
&amp;nbsp;&amp;nbsp;&amp;nbsp; land_area = row2.getValue("Land_Area")
&amp;nbsp;&amp;nbsp;&amp;nbsp; if land_area &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(parcels, "UTC10_Pct", """[UTC10_Ft]/[Land_Area] """, "VB")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Overflow Error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know I can get around this using a selection, but seems like should simply run from Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone tell why this isn't working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 19:02:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675242#M52247</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-11-23T19:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: If statement won't bypass zeros</title>
      <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675243#M52248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As far as I know, the calculate field tool processes on the entire field, not on your current search cursor selection. I could be wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why not use update cursor? Much better than calculate field. And why not use a selection instead of a search cursor?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 19:39:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675243#M52248</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-11-23T19:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: If statement won't bypass zeros</title>
      <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675244#M52249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Mathew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, that makes sense. I'm still gaining comfort with moving into python away from the tools I know. I will try incorporating the update cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have run the tool using the selection successfully. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch for your feedback.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 20:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675244#M52249</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-11-23T20:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: If statement won't bypass zeros</title>
      <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675245#M52250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Calculate field is used on the whole field, use an updatecursor as suggested, then put in an else section telling what to do if the divisor is 0&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 20:10:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675245#M52250</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-11-23T20:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: If statement won't bypass zeros</title>
      <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675246#M52251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dan Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What I have been reading suggests an If statement can be singular without an else statement. Perhaps your experience is otherwise. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RT&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 20:52:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675246#M52251</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-11-23T20:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: If statement won't bypass zeros</title>
      <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675247#M52252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would recommend something as follows. You could use the getValue instead of row references too. Format where statement as needed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
where = "\"Land_Area\" &amp;gt; 0"
rows2 = arcpy.UpdateCursor(parcels, where)
for row2 in rows2:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.UTC10_Pct = row.UTC10_Ft / row.Land_Area
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows2.updateRow(row2)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:28:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675247#M52252</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T04:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: If statement won't bypass zeros</title>
      <link>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675248#M52253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Works awesome. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2011 22:45:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-statement-won-t-bypass-zeros/m-p/675248#M52253</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-12-08T22:45:40Z</dc:date>
    </item>
  </channel>
</rss>

