<?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: Else if or maybe Where Clause for Update Cursor. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130766#M10169</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Pretty close, you just need one row reference though for your range. One other thing, you don't need to update your row after each if statement, you can just do it once at the end to save some lines. You also had an "O" in your first if statement instead of a zero.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;rows = arcpy.UpdateCursor(STHDLINES) for row in rows:&amp;nbsp; if row.Bkf_W &amp;lt;= 0: &amp;nbsp; row.Width_Cat = 0&amp;nbsp; elif 0 &amp;lt; Bkf_W &amp;lt;= 3: &amp;nbsp; row.Width_Cat = 1&amp;nbsp; elif 3 &amp;lt; Bkf_W &amp;lt;= 50: &amp;nbsp; row.Width_Cat = 2&amp;nbsp; elif row.Bkf_W &amp;gt; 50: &amp;nbsp; row.Width_Cat = 3&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are most likely having issues with Notepad++ because it doesn't discriminate between tabs and spaces as well as other IDEs do.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Apr 2013 15:45:40 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2013-04-25T15:45:40Z</dc:date>
    <item>
      <title>Else if or maybe Where Clause for Update Cursor.</title>
      <link>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130763#M10166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have several conditional statements I want to use to update values in an attribute table. I have been using update cursors as of late with some success. But now I am at a point that I am struggling with. I am able to use single argument conditions like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if row.Bkf_W &amp;lt;= 0: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Width_Cat = 0 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row.NEAR_DIST &amp;gt; 100: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Snap_Code = 0 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But what if I want to check a range of values. Like : Bkf_W &amp;gt; 0 and Bfw_W &amp;lt;=3 then Width_Cat = 1. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Would it be 0 &amp;lt; Bkf_W &amp;lt;= 3, then Width_Cat = 1? I have several of these "range" conditions (8 total) that I want to use to update cursors. Any help would be appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 14:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130763#M10166</guid>
      <dc:creator>ChristopherClark1</dc:creator>
      <dc:date>2013-04-25T14:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Else if or maybe Where Clause for Update Cursor.</title>
      <link>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130764#M10167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not sure what you are asking. Do you just need to figure out python syntax?&amp;nbsp; 0 &amp;lt; Bkf_W &amp;lt;= 3 is perfectly valid, though your indentation is off in the code you posted.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 14:24:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130764#M10167</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-04-25T14:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Else if or maybe Where Clause for Update Cursor.</title>
      <link>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130765#M10168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry about the indentation. For some reason when I script things in Notepad++ then move it over to IDLE the indentations are always off. It looks good in notepad++ . &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yea, I was trying to figure out the syntax. So this will work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(STHDLINES)
for row in rows:
 if row.Bkf_W &amp;lt;= O:
&amp;nbsp; row.Width_Cat = 0
&amp;nbsp; rows.updateRow(row)
 elif row.Bkf_W 0 &amp;lt; Bkf_W &amp;lt;= 3:
&amp;nbsp; row.Width_Cat = 1
&amp;nbsp; rows.updateRow(row)
 elif row.Bkf_W 3 &amp;lt; Bkf_W &amp;lt;= 50:
&amp;nbsp; row.Width_Cat = 2
&amp;nbsp; rows.updateRow(row)
 elif row.Bkf_W &amp;gt; 50:
&amp;nbsp; row.Width_Cat = 3
&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:21:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130765#M10168</guid>
      <dc:creator>ChristopherClark1</dc:creator>
      <dc:date>2021-12-11T07:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Else if or maybe Where Clause for Update Cursor.</title>
      <link>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130766#M10169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Pretty close, you just need one row reference though for your range. One other thing, you don't need to update your row after each if statement, you can just do it once at the end to save some lines. You also had an "O" in your first if statement instead of a zero.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;rows = arcpy.UpdateCursor(STHDLINES) for row in rows:&amp;nbsp; if row.Bkf_W &amp;lt;= 0: &amp;nbsp; row.Width_Cat = 0&amp;nbsp; elif 0 &amp;lt; Bkf_W &amp;lt;= 3: &amp;nbsp; row.Width_Cat = 1&amp;nbsp; elif 3 &amp;lt; Bkf_W &amp;lt;= 50: &amp;nbsp; row.Width_Cat = 2&amp;nbsp; elif row.Bkf_W &amp;gt; 50: &amp;nbsp; row.Width_Cat = 3&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are most likely having issues with Notepad++ because it doesn't discriminate between tabs and spaces as well as other IDEs do.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 15:45:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/else-if-or-maybe-where-clause-for-update-cursor/m-p/130766#M10169</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-04-25T15:45:40Z</dc:date>
    </item>
  </channel>
</rss>

