<?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: query issues with Update Cursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/query-issues-with-update-cursor/m-p/681104#M52781</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Matthew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you. I realize I am stepping all over myself trying to learn and implement Python into my workflow. I appreciate the assistance..&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Sep 2012 13:12:09 GMT</pubDate>
    <dc:creator>stephengushue</dc:creator>
    <dc:date>2012-09-28T13:12:09Z</dc:date>
    <item>
      <title>query issues with Update Cursor</title>
      <link>https://community.esri.com/t5/python-questions/query-issues-with-update-cursor/m-p/681102#M52779</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;I am working on an update cursor on a contour line feature class. The goal is to update a field "INDEX_VALU" with the string "10 foot Index" where data in the "CONTOUR" field are divisible by 10. In tests I was success when setting a simple query as shown:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;query = ' "CONTOUR" = 5100'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The issues occurs when I try to modify this query to include all values divisible by 10. I believe the modulo operator is the way forward, but they query keeps getting rejected. Enclosed is my latest attempt at solving this. Any help will be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Script Name: contourindexcalc.py # Author: Stephen Gushue # Purpose: Find and calculate values of the contours to illustrate 10 foot contours&amp;nbsp; # Import system modules import arcpy, sys, traceback from arcpy import env&amp;nbsp; # Set workspace arcpy.env.workspace = 'U:\\GEO\\projects\\python'&amp;nbsp; # Local Variables featureclass = 'contours_test.shp' fieldlist = arcpy.ListFields (featureclass)&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; # Sets row hold query &amp;nbsp;&amp;nbsp;&amp;nbsp; setfield = '"CONTOUR"%' &amp;nbsp;&amp;nbsp;&amp;nbsp; query = 'setfield == 0'&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a Search Cursor &amp;nbsp;&amp;nbsp;&amp;nbsp; srows = arcpy.SearchCursor (featureclass, query)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for srow in srows:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # assign a variable for the value of srow.CONTOUR &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # assign a variable for the value of srow.INDEX_VALU &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contour = srow.CONTOUR &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; index = srow.INDEX_VALU &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;&amp;nbsp;&amp;nbsp; # Create Update Cursor &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urows = arcpy.UpdateCursor(featureclass, query)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cycle through the rows &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # to actually update the row in the cursor &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # with the values obtained from the search cursor &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for urow in urows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urow.INDEX_VALU = "10 Foot Index" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urows.updateRow(urow)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; print 'DONE' &amp;nbsp;&amp;nbsp;&amp;nbsp; del urow, urows, srow, srows&amp;nbsp; except:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tb = sys.exc_info()[2] &amp;nbsp;&amp;nbsp;&amp;nbsp; tbinfo = traceback.format_tb(tb)[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n" &amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = "ARCPY ERRORS:\n" + arcpy.GetMessages(2) + "\n"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(pymsg)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs &amp;nbsp;&amp;nbsp;&amp;nbsp; print pymsg&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:00:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-issues-with-update-cursor/m-p/681102#M52779</guid>
      <dc:creator>stephengushue</dc:creator>
      <dc:date>2012-09-27T20:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: query issues with Update Cursor</title>
      <link>https://community.esri.com/t5/python-questions/query-issues-with-update-cursor/m-p/681103#M52780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think you need to start at square one here. There is no reason to use a search cursor and an update cursor at the same time on the same feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should be all you need in your try statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;try: &amp;nbsp;&amp;nbsp;&amp;nbsp; # Create Update Cursor &amp;nbsp;&amp;nbsp;&amp;nbsp; urows = arcpy.UpdateCursor(featureclass)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Cycle through the rows &amp;nbsp;&amp;nbsp;&amp;nbsp; # to actually update the row in the cursor &amp;nbsp;&amp;nbsp;&amp;nbsp; # with the values obtained from the search cursor &amp;nbsp;&amp;nbsp;&amp;nbsp; for urow in urows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contour = urow.CONTOUR &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if int(float(contour) / 10) == (float(contour) / 10): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urow.INDEX_VALU = "10 Foot Index" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urows.updateRow(urow)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; print 'DONE' &amp;nbsp;&amp;nbsp;&amp;nbsp; del urow, urows&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:25:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-issues-with-update-cursor/m-p/681103#M52780</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-09-27T20:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: query issues with Update Cursor</title>
      <link>https://community.esri.com/t5/python-questions/query-issues-with-update-cursor/m-p/681104#M52781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Matthew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you. I realize I am stepping all over myself trying to learn and implement Python into my workflow. I appreciate the assistance..&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 13:12:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-issues-with-update-cursor/m-p/681104#M52781</guid>
      <dc:creator>stephengushue</dc:creator>
      <dc:date>2012-09-28T13:12:09Z</dc:date>
    </item>
  </channel>
</rss>

