<?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: Update Cursor not updating field with value in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240902#M18756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I rewrote the code to use the for loop.&amp;nbsp; I got the same problem at first (all null values in the attribute table), I went into field calculator and closed it without entering any code and VOILA, the correct values were in the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if they would have been had I gone into the field calculator after running the while loop or not, but success none the less.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any "refresh" method that would fix this??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Feb 2012 16:23:45 GMT</pubDate>
    <dc:creator>RoyHewitt</dc:creator>
    <dc:date>2012-02-14T16:23:45Z</dc:date>
    <item>
      <title>Update Cursor not updating field with value</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240900#M18754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm writing a script for field staff that clips all wetlands in a watershed, calculates area (hectares) and multiples by a sampling factor to see how many hectares need to be sample&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a sample of the update cursor part of the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(newWetland) row = rows.next()&amp;nbsp; while row: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.getValue(wetlandTypeField) == 'Estuarine and Marine Wetland': &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; totalHectares = row.getValue(areaField) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sampleArea = (totalHectares * .25) # Sample 25% of this type &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(sampleField, sampleArea) &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; row = rows.next() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row.getValue(wetlandTypeField) == 'Freshwater Emergent Wetland': &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; totalHectares = row.getValue(areaField) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sampleArea = (totalHectares * .25) # Sample 25% of this type &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(sampleField, sampleArea) &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; row = rows.next()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are several more elif blocks for each wetland type in the dataset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I type in the python window:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;print sampleArea&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the correct area, however, it does not update the row.&amp;nbsp; The help files indicate that the second parameter of the row.setValue() method is supposed to be an object.&amp;nbsp; Could that be the problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Roy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2012 15:39:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240900#M18754</guid>
      <dc:creator>RoyHewitt</dc:creator>
      <dc:date>2012-02-14T15:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor not updating field with value</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240901#M18755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;have you tried to use the "for row in rows:" syntax as shown in the online help for updaterow?&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2012 15:54:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240901#M18755</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2012-02-14T15:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor not updating field with value</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240902#M18756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I rewrote the code to use the for loop.&amp;nbsp; I got the same problem at first (all null values in the attribute table), I went into field calculator and closed it without entering any code and VOILA, the correct values were in the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if they would have been had I gone into the field calculator after running the while loop or not, but success none the less.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any "refresh" method that would fix this??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2012 16:23:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240902#M18756</guid>
      <dc:creator>RoyHewitt</dc:creator>
      <dc:date>2012-02-14T16:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor not updating field with value</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240903#M18757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The table doesn't get refreshed.&amp;nbsp; Run scripts etc, then open the table, don't expect updates unless you are using the field calculator directly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2012 17:24:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-not-updating-field-with-value/m-p/240903#M18757</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2012-02-14T17:24:33Z</dc:date>
    </item>
  </channel>
</rss>

