<?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 parsing error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343527#M26877</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You're mixing up arcpy.SearchCursor and arcpy.da.SearchCursor, among other issues (missing closing parens, indentation).&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency" mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small"&amp;nbsp; lutDict = {r[0]: r[1] for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"])}&amp;nbsp; with arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) as updateRows: &amp;nbsp;&amp;nbsp;&amp;nbsp; for updateRow in updateRows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nameValue = updateRow[0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if nameValue in lutDict: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = lutDict[nameValue][0]&amp;nbsp; #Address &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Oct 2013 21:23:48 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2013-10-22T21:23:48Z</dc:date>
    <item>
      <title>Update Cursor parsing error</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343526#M26876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am putting together some snippets of code and running into a parsing error: Parsing error SyntaxError: invalid syntax (line 8).&amp;nbsp; The error seems to be on line: updateRows = arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; I have tried all types of fixes, but cannot find the problem.&amp;nbsp; I am running on 10.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency" mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small"&amp;nbsp; lutDict = dict([(r.FULL_ADDRESS, (r.FREQUENCY)) for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"])&amp;nbsp; updateRows = arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) for updateRow in updateRows: &amp;nbsp;&amp;nbsp;&amp;nbsp; nameValue = updateRow.FULL_ADDRSS&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if nameValue in lutDict: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = lutDict[nameValue][0]&amp;nbsp; #Address &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow) del updateRow, updateRows &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 21:12:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343526#M26876</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-22T21:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor parsing error</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343527#M26877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You're mixing up arcpy.SearchCursor and arcpy.da.SearchCursor, among other issues (missing closing parens, indentation).&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency" mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small"&amp;nbsp; lutDict = {r[0]: r[1] for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"])}&amp;nbsp; with arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) as updateRows: &amp;nbsp;&amp;nbsp;&amp;nbsp; for updateRow in updateRows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nameValue = updateRow[0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if nameValue in lutDict: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = lutDict[nameValue][0]&amp;nbsp; #Address &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 21:23:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343527#M26877</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2013-10-22T21:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor parsing error</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343528#M26878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;With your changes, I am now getting a new error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 12, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TypeError: 'int' object has no attribute '__getitem__&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;based on this row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

updateRow[1] = lutDict[nameValue][0]

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:11:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343528#M26878</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2021-12-11T16:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor parsing error</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343529#M26879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;updateRow[1] = lutDict[nameValue]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Still don't quite understand what you're doing here.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 22:33:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343529#M26879</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2013-10-22T22:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor parsing error</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343530#M26880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The purpose of the code is to match the frequency table (convert it into a python dictionary), and then update a field in another file.&amp;nbsp; In other words it is a fast way of doing a join/calc.&amp;nbsp; If I understand the source where I got some of the code correctly, I am transferring the FREQUENCY filed data from the frequency.dbf (lutTbl) file into the mainTbl by way matching through the FULL_ADDRESS filed in each table.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 22:55:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343530#M26880</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-22T22:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor parsing error</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343531#M26881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I was able to get the code working (without any errors) after I removed the [0] after the lutDict[nameValue] in code row: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;updateRow[1] = lutDict[nameValue]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However It is not updating any new data in the mainTble field.&amp;nbsp; Not sure where the code is going wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Clinton&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Oct 2013 17:07:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343531#M26881</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2013-10-23T17:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor parsing error</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343532#M26882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You're mixing up arcpy.SearchCursor and arcpy.da.SearchCursor, among other issues (missing closing parens, indentation).&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency"
mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small"

lutDict = {r[0]: r[1] for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"])}

with arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) as updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for updateRow in updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nameValue = updateRow[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if nameValue in lutDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = lutDict[nameValue][0]&amp;nbsp; #Address
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This solution worked after I removed the [0] bracket and added the del updateRow, updateRows&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:11:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-parsing-error/m-p/343532#M26882</guid>
      <dc:creator>ClintonCooper1</dc:creator>
      <dc:date>2021-12-11T16:11:37Z</dc:date>
    </item>
  </channel>
</rss>

