<?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: Row in table not updating with cursor (HELP) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159586#M64229</link>
    <description>&lt;P&gt;I'm not exactly sure what you're trying to accomplish here. Are you trying to check if the actual geometry lattitude is in your list and then update the new field "Lattitude" accordingly?&amp;nbsp; If so, you will need to specify the feature geometry field (using "SHAPE@", or "SHAPE@XY", for example) and use that instead.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As to why it's not updating anything: currently in line 21 of your script, you're checking for each row if the value for field2 ("Lattitude"), which I assume is empty since you're adding the field as a new field, is in your list LatY. This is probably why nothing is updated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2022 18:55:50 GMT</pubDate>
    <dc:creator>HuubZwart</dc:creator>
    <dc:date>2022-03-30T18:55:50Z</dc:date>
    <item>
      <title>Row in table not updating with cursor (HELP)</title>
      <link>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159574#M64227</link>
      <description>&lt;P&gt;Hello everyone! I created a feature class and I'm trying to update the attribute table with cursors. I created a list of coordinates (LatY) that I want to input into the "Latitude" column on my table, code works, however, my table isn't updating.&lt;/P&gt;&lt;P&gt;I'm attaching my code plus a screenshot of my table. I appreciate the help!!&lt;/P&gt;&lt;P&gt;PD: I know I can update those fields in an easier way, but the purpose of my project is to create everything using code&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot_2.png" style="width: 200px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37761iD01C4FE47806D0BF/image-size/small?v=v2&amp;amp;px=200" role="button" title="Screenshot_2.png" alt="Screenshot_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import numpy as np 
import pandas as pd

arcpy.env.workspace = r"C:\Users\andre\Desktop\Project\NewCores"
fc2 = r"C:\Users\andre\Desktop\Project\NewCores.shp"
field1 = ["Core_ID"]
field2 = ["Latitude"]
field3 = ["Longitude"]
field4 = ["Depth"]
arcpy.AddField_management(fc2, "Core_ID","TEXT")
arcpy.AddField_management(fc2, "Latitude","LONG")
arcpy.AddField_management(fc2, "Longitude","LONG")

LatY = (30.11386111,30.11369444,30.11380556,30.109,30.11022222,30.11175,
        30.10355556,30.10380556,30.10352778,30.10366667,30.10558333,30.10436111)

#Write code to get latitude
cursor = arcpy.da.UpdateCursor(fc2, field2)
for row in cursor:
    if row[0] in LatY:
        row[1] = LatY[row[0]]
        cursor.updateRow(row)

del cursor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 18:40:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159574#M64227</guid>
      <dc:creator>AndreaGG6</dc:creator>
      <dc:date>2022-03-30T18:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Row in table not updating with cursor (HELP)</title>
      <link>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159583#M64228</link>
      <description>&lt;P&gt;I don't understand row[1] as you only have one field so row will only have one element row[0].&lt;/P&gt;&lt;P&gt;If you are trying to populate the 12 values on row at a time (assuming they come out in order, which isn't guaranteed, depending on data source) I think this is the pattern you want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(fc2, field2) as rows:
    k = 1
    for row in rows:
        row[0] = LatY[k]
        rows.updateRow(row)
        k += 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If order becomes a problem you can use the ID field:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(fc2, ["ID", "Latitude"]) as rows:
    for row in rows:
        row[1] = LatY[row[0] - 1] # index 0 to 11 (IDs are 1 to 12)
        rows.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more issue, your latitude field must be FLOAT or DOUBLE not LONG (LONG will truncate all data to integer when you assign it to the field!)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 19:01:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159583#M64228</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-03-30T19:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Row in table not updating with cursor (HELP)</title>
      <link>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159586#M64229</link>
      <description>&lt;P&gt;I'm not exactly sure what you're trying to accomplish here. Are you trying to check if the actual geometry lattitude is in your list and then update the new field "Lattitude" accordingly?&amp;nbsp; If so, you will need to specify the feature geometry field (using "SHAPE@", or "SHAPE@XY", for example) and use that instead.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As to why it's not updating anything: currently in line 21 of your script, you're checking for each row if the value for field2 ("Lattitude"), which I assume is empty since you're adding the field as a new field, is in your list LatY. This is probably why nothing is updated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 18:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159586#M64229</guid>
      <dc:creator>HuubZwart</dc:creator>
      <dc:date>2022-03-30T18:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Row in table not updating with cursor (HELP)</title>
      <link>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159601#M64231</link>
      <description>&lt;P&gt;Beyond the calculations options...&lt;/P&gt;&lt;P&gt;The table might not update if the table is open.&amp;nbsp; So you might want to close the table, run the script, then open the table to see if that is the issue.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 19:25:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159601#M64231</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-03-30T19:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Row in table not updating with cursor (HELP)</title>
      <link>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159606#M64232</link>
      <description>&lt;P&gt;Thank you so much for your help! the first code didn't work and ended up with "Line &lt;SPAN class=""&gt;27&lt;/SPAN&gt;: row[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;] = LatY[k] &lt;SPAN class=""&gt;IndexError&lt;/SPAN&gt;: tuple index out of range".&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second one worked!&amp;nbsp; I created more fields now and it works with "Double". One more question,&amp;nbsp;I have to update another field with 'TEXT', would these two codes work with that data type?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 19:39:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159606#M64232</guid>
      <dc:creator>AndreaGG6</dc:creator>
      <dc:date>2022-03-30T19:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Row in table not updating with cursor (HELP)</title>
      <link>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159636#M64233</link>
      <description>Ah, I should have started with k=0 for the first example (I will fix that for the good of the thread)&lt;BR /&gt;You can assign text, but you need to make sure the value you are assigning to a text type field is text. Python handles data types for you.&lt;BR /&gt;You do know that assigning latitude will not set the point location, right? You'd have to use the shape field to do that (kind of advanced stuff).&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Mar 2022 20:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/row-in-table-not-updating-with-cursor-help/m-p/1159636#M64233</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-03-30T20:26:57Z</dc:date>
    </item>
  </channel>
</rss>

