<?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: Updating a newly generated field with an update cursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updating-a-newly-generated-field-with-an-update/m-p/1067920#M61362</link>
    <description>&lt;P&gt;you've saved my sanity Johannes I really appreciate it!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DanielFuller_0-1623681583340.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15882i8C732F7A7B070FB6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DanielFuller_0-1623681583340.png" alt="DanielFuller_0-1623681583340.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jun 2021 14:39:53 GMT</pubDate>
    <dc:creator>DanielFuller</dc:creator>
    <dc:date>2021-06-14T14:39:53Z</dc:date>
    <item>
      <title>Updating a newly generated field with an update cursor</title>
      <link>https://community.esri.com/t5/python-questions/updating-a-newly-generated-field-with-an-update/m-p/1067889#M61360</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing rural-urban data that I need to process.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DanielFuller_1-1623678861803.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15879i79E791D9C794657C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DanielFuller_1-1623678861803.png" alt="DanielFuller_1-1623678861803.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code generates the isUrban field, I then need to use an update cursor to classify that field as "Rural" or "Urban" based off of the RUC11CD field (I'm currently trying to do this as a boolean), if RUC11CD is equal to or greater than "4" it needs to be classified as "Urban" (or true if i stick with boolean) . i've read the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/updatecursor-class.htm" target="_self"&gt;documentation&lt;/A&gt; on update cursors and watched some &lt;A href="https://www.youtube.com/watch?v=1_aqakXMo8Y" target="_self"&gt;videos.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but i've been stuck for 3 days with no idea what i'm doing wrong. my cursor iterates through my table but classifies everything as false (see screenshot). my cursor code currently looks like this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;field_Name = "isUrban"
field_Nametype = "INTEGER"
field_NameVal = arcpy.ValidateFieldName(field_Name)

#Adds the new field if it doesn't already exist
fList = arcpy.ListFields(fc,field_Name)
if not fList:
    arcpy.AddField_management(fc, field_Name, field_Nametype, "", "", "")
    sheet = arcpy.management.MakeTableView(Rural)
    fieldcheck = arcpy.ListFields(sheet, "isUrban")

    if len(fieldcheck) == 0:
        arcpy.AddField_management(sheet, "isUrban", 'INTEGER')
    if len(fieldcheck) == 1:
        arcpy.DeleteField_management(sheet, "isUrban")
        arcpy.AddField_management(sheet, "isUrban", 'INTEGER')

fields = ["RUC11CD", "isUrban"]

# Create update cursor for feature class
with arcpy.da.UpdateCursor(Rural, fields) as cursor:
    for row in cursor:
        if fields[0] &amp;gt;3:
            fields[1] = True
        else:
            fields[1] = False
        cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;if i set the new field to be a string and the fields to be 'true' or 'false' as strings the field returns blank cells&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 13:58:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-a-newly-generated-field-with-an-update/m-p/1067889#M61360</guid>
      <dc:creator>DanielFuller</dc:creator>
      <dc:date>2021-06-14T13:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a newly generated field with an update cursor</title>
      <link>https://community.esri.com/t5/python-questions/updating-a-newly-generated-field-with-an-update/m-p/1067902#M61361</link>
      <description>&lt;LI-CODE lang="python"&gt;# you're checking and changing fields, not row!

# if you do this, it should work:
for row in cursor:
    is_urban = row[0] &amp;gt; 3
    cursor.updateRow([row[0], is_urban])

# even shorter:
for row in cursor:
    cursor.updateRow([row[0], row[0] &amp;gt; 3])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Also: you can replace lines 6 to 16 with this
try:
    arcpy.management.DeleteField(fc, "isUrban")
except:
    pass
arcpy.management.AddField(fc, "isUrban", "INTEGER")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 14 Jun 2021 14:15:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-a-newly-generated-field-with-an-update/m-p/1067902#M61361</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-14T14:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a newly generated field with an update cursor</title>
      <link>https://community.esri.com/t5/python-questions/updating-a-newly-generated-field-with-an-update/m-p/1067920#M61362</link>
      <description>&lt;P&gt;you've saved my sanity Johannes I really appreciate it!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DanielFuller_0-1623681583340.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15882i8C732F7A7B070FB6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DanielFuller_0-1623681583340.png" alt="DanielFuller_0-1623681583340.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 14:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-a-newly-generated-field-with-an-update/m-p/1067920#M61362</guid>
      <dc:creator>DanielFuller</dc:creator>
      <dc:date>2021-06-14T14:39:53Z</dc:date>
    </item>
  </channel>
</rss>

