<?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: Question on ´GIS Tutorial for Python Scripting´ working with cursorsl in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/question-on-acute-gis-tutorial-for-python/m-p/241170#M18767</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A few errors in the code.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;row[1] is the buffer value you try to assign, so you should write to it, without it, it doesn't make sense to update the row, since nothing changes&lt;/LI&gt;&lt;LI&gt;delete the cursor and row outside the with statement, otherwise you are "cutting the branch you're sitting on"&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = r"C:\EsriPress\GISTPython\Data\City of Oleander.gdb"
env.overwriteOutput = True
updateFC = "StreetLights"
with arcpy.da.UpdateCursor(updateFC, ["TYPE", "Buffer"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYPE = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if TYPE == "MV":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = 125
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = 200
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
del cursor, row&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:06:22 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-11T12:06:22Z</dc:date>
    <item>
      <title>Question on ´GIS Tutorial for Python Scripting´ working with cursorsl</title>
      <link>https://community.esri.com/t5/python-questions/question-on-acute-gis-tutorial-for-python/m-p/241169#M18766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I´m trying to work my way through the ´GIS Tutorial for Python Scripting´ by David Allen. Working with cursors (Tutorial 2.3) is giving me a hard time as there seem to be a number of ways to approach this subject, but I can´t make any sense of them. What confuses me most is the numbering in the syntax. Can anybody helmp me with Exercise 2.3? The problem seems to be a non-defined cursor name, but I´m lost here. This is the code I´ve come up with so far:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;env.workspace = r"C:\EsriPress\GISTPython\Data\City of Oleander.gdb"&lt;/P&gt;&lt;P&gt;env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;updateFC = "StreetLights"&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor("StreetLights",["TYPE", "Buffer"]) as cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYPE = row[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Buffer = row[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if TYPE == "MV":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Buffer = 125&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Buffer = 200&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "All done updating"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cursor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del row&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 21:35:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-on-acute-gis-tutorial-for-python/m-p/241169#M18766</guid>
      <dc:creator>Ericvan_Rees</dc:creator>
      <dc:date>2015-02-24T21:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Question on ´GIS Tutorial for Python Scripting´ working with cursorsl</title>
      <link>https://community.esri.com/t5/python-questions/question-on-acute-gis-tutorial-for-python/m-p/241170#M18767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A few errors in the code.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;row[1] is the buffer value you try to assign, so you should write to it, without it, it doesn't make sense to update the row, since nothing changes&lt;/LI&gt;&lt;LI&gt;delete the cursor and row outside the with statement, otherwise you are "cutting the branch you're sitting on"&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = r"C:\EsriPress\GISTPython\Data\City of Oleander.gdb"
env.overwriteOutput = True
updateFC = "StreetLights"
with arcpy.da.UpdateCursor(updateFC, ["TYPE", "Buffer"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYPE = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if TYPE == "MV":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = 125
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = 200
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
del cursor, row&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:06:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-on-acute-gis-tutorial-for-python/m-p/241170#M18767</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T12:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Question on ´GIS Tutorial for Python Scripting´ working with cursorsl</title>
      <link>https://community.esri.com/t5/python-questions/question-on-acute-gis-tutorial-for-python/m-p/241171#M18768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your clear explanation, this is very helpful.&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 21:58:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-on-acute-gis-tutorial-for-python/m-p/241171#M18768</guid>
      <dc:creator>Ericvan_Rees</dc:creator>
      <dc:date>2015-02-24T21:58:19Z</dc:date>
    </item>
  </channel>
</rss>

