<?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: arcpy.da.UpdateCursor on joined tables? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179641#M13776</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, thanks, I'll keep digging and will surely find the problem at some point.&amp;nbsp; Thanks for posting the alternate syntax -- it is definitely much easier to read.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 May 2013 19:59:52 GMT</pubDate>
    <dc:creator>ErikMartin</dc:creator>
    <dc:date>2013-05-01T19:59:52Z</dc:date>
    <item>
      <title>arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179630#M13765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Do data access update cursors work on joined tables?&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://gis.stackexchange.com/questions/57269/searchcursor-arcpy-da-accessing-data-on-joined-tables" rel="nofollow" target="_blank"&gt;This thread&lt;/A&gt;&lt;SPAN&gt; indicates that Search Cursors do, but I keep getting a "cannot update join table" error.&amp;nbsp; I have confirmed that I am trying to update the original table, not the joined table.&amp;nbsp; Here's the pertinent code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.MakeFeatureLayer_management(FC, "FC_lyr") FC_lyr = "FC_lyr" arcpy.AddJoin_management(FC_lyr, "joinField", joinedFCTable, "joinField")&amp;nbsp; fields =("{}.DataField".format(FC_lyr), "{}.OtherDataFiedl".format(joinedFCTable)) where = '"{}.OBJECTID" IS NOT NULL'.format(joinedFCTable)&amp;nbsp; with arcpy.da.UpdateCursor(FC_lyr, fields, where) as rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = row[0] + row[1] &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an aside, I am trying to use the da.UpdateCursor because &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/78688-arcpy.da.UpdateCursor-use-variable-as-field-index?p=276979&amp;amp;viewfull=1#post276979" rel="nofollow" target="_blank"&gt;it is far faster&lt;/A&gt;&lt;SPAN&gt; than using field the calculator (code that I already have working) &amp;amp; I am trying to optimize speed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 13:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179630#M13765</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-01T13:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179631#M13766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've had nothing but problems trying to update fields in a joined table. I would recommend reading this post and examining the attached scripts for ideas on how to get around these issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/71572-Using-Python-Dictionaries-with-Update-Cursors-instead-of-quot-Join-and-Calculate-quot"&gt;http://forums.arcgis.com/threads/71572-Using-Python-Dictionaries-with-Update-Cursors-instead-of-quot-Join-and-Calculate-quot&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also have a post from a while back using similar methodology in a more specific case example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/55099-Update-cursor-with-joined-tables-work-around-w-dictionaries"&gt;http://forums.arcgis.com/threads/55099-Update-cursor-with-joined-tables-work-around-w-dictionaries&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 13:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179631#M13766</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-05-01T13:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179632#M13767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using a dictionary and an update cursor in tandem is the solution.... It's actually pretty straight forward:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A basic example in v10.1 syntax that "joins" two fields from the lutTbl to the targetTbl:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lutDict = dict([(r[0], (r[1], r[2])) for r in arcpy.da.SearchCursor(lutTbl, ["SOURCEJOINFIELD","SOURCEFIELD1","SOURCEFIELD2"])])
updateRows = arcpy.da.UpdateCursor(targetTbl, ["TARGETJOINFIELD","TARGETFIELD1","TARGFETFIELD2"])
for updateRow in updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; joinFieldValue = updateRow[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = lutDict[joinFieldValue][0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[2] = lutDict[joinFieldValue][1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179632#M13767</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T09:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179633#M13768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you both for your prompt responses.&amp;nbsp; These examples are very helpful.&amp;nbsp; I've been able to get this working to update field values using joined values, but my understanding of dictionaries is pretty rudimentary at this point... Do either of you have any hints or example of how to do some simple arithmetic?&amp;nbsp; My two calculations are simply &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;updateValue = joinValue + updateValue &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;updateValue = joinValue * updateValue&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have yet to get the syntax right using the dictionary method.&amp;nbsp; Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 15:32:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179633#M13768</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-01T15:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179634#M13769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thank you both for your prompt responses.&amp;nbsp; These examples are very helpful.&amp;nbsp; I've been able to get this working to update field values using joined values, but my understanding of dictionaries is pretty rudimentary at this point... Do either of you have any hints or example of how to do some simple arithmetic?&amp;nbsp; My two calculations are simply &lt;BR /&gt;&lt;BR /&gt;updateValue = joinValue + updateValue &lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;BR /&gt;updateValue = joinValue * updateValue&lt;BR /&gt;&lt;BR /&gt;I have yet to get the syntax right using the dictionary method.&amp;nbsp; Thanks,&lt;BR /&gt;-Erik&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Would I make 2 dictionaries from 2 SearchCursors?&amp;nbsp; One on the update data and a second on the joined data?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 15:34:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179634#M13769</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-01T15:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179635#M13770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Would I make 2 dictionaries from 2 SearchCursors?&amp;nbsp; One on the update data and a second on the joined data?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I would only look at creating a dictionary of your reference data. You can then cursor through your table you want to update referencing the key in your dictionary with the join field to access the dictionary value. If you don't have much experience with dictionaries I'm sure it is very confusing, but once you try it out they are quite simple.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 15:54:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179635#M13770</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-05-01T15:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179636#M13771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not sure why you would need to make two dictionaries (maybe if you had two look up tables?).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dictionaries are a great way to store tabular information... with the concept that you have a "key" field and then a bunch of other values that are associated with the key... sounds like a RDBMS table, right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;dict = {}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dict["cat"] = [1, "fish", 5.7654]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dict["dog"] = [3, "garbage", 15.5]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this case the key is a string "cat", which is associated with a list of values (age, diet, and weight maybe).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Keys must be unique, but can be strings, integers, floats, or even "tuples" such as a value of&amp;nbsp; (1,2). Tuple keys can be extreemly usefull.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You retreive values like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#get the diet of "cat"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print dict["cat"][1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'fish'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dictionaries are great since they are EXTREEMLY fast to access, but a downside is that their size is limited by how much RAM you have.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway to do math per my earlier example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lutDict = dict([(r[0], (r[1], r[2])) for r in arcpy.da.SearchCursor(lutTbl, ["SOURCEJOINFIELD","SOURCEFIELD1","SOURCEFIELD2"])])
updateRows = arcpy.da.UpdateCursor(targetTbl, ["TARGETJOINFIELD","TARGETFIELD1","TARGFETFIELD2"])
for updateRow in updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; joinFieldValue = updateRow[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = updateRow[1] + lutDict[joinFieldValue][0] #assuming these values are numeric and not strings or anything!
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[2] = updateRow[2] * lutDict[joinFieldValue][1] #assuming these values are numeric and not strings or anything!
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179636#M13771</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T09:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179637#M13772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Not sure why you would need to make two dictionaries (maybe if you had two look up tables?).&lt;BR /&gt;&lt;BR /&gt;Dictionaries are a great way to store tabular information... with the concept that you have a "key" field and then a bunch of other values that are associated with the key... sounds like a RDBMS table, right?&lt;BR /&gt;&lt;BR /&gt;dict = {}&lt;BR /&gt;dict["cat"] = [1, "fish", 5.7654]&lt;BR /&gt;dict["dog"] = [3, "garbage", 15.5]&lt;BR /&gt;&lt;BR /&gt;In this case the key is a string "cat", which is associated with a list of values (age, diet, and weight maybe).&lt;BR /&gt;Keys must be unique, but can be strings, integers, floats, or even "tuples" such as a value of&amp;nbsp; (1,2). Tuple keys can be extreemly usefull.&lt;BR /&gt;&lt;BR /&gt;You retreive values like this:&lt;BR /&gt;&lt;BR /&gt;#get the diet of "cat"&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; print dict["cat"][1]&lt;BR /&gt;'fish'&lt;BR /&gt;&lt;BR /&gt;Dictionaries are great since they are EXTREEMLY fast to access, but a downside is that their size is limited by how much RAM you have.&lt;BR /&gt;&lt;BR /&gt;Anyway to do math per my earlier example:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lutDict = dict([(r[0], (r[1], r[2])) for r in arcpy.da.SearchCursor(lutTbl, ["SOURCEJOINFIELD","SOURCEFIELD1","SOURCEFIELD2"])])
updateRows = arcpy.da.UpdateCursor(targetTbl, ["TARGETJOINFIELD","TARGETFIELD1","TARGFETFIELD2"])
for updateRow in updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; joinFieldValue = updateRow[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = updateRow[1] + lutDict[joinFieldValue][0] #assuming these values are numeric and not strings or anything!
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[2] = updateRow[2] * lutDict[joinFieldValue][1] #assuming these values are numeric and not strings or anything!
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This makes perfect sense... thanks to you both!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179637#M13772</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2021-12-11T09:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179638#M13773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This makes perfect sense&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Practice makes perfect... It took me a while to get proficient with dictonaries (aka "hash tables").&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, once I "got it"... one of the most powerfull tricks I have, and allows for some pretty cool stuff.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Some very basic usefull dictionary methods:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;dict = {}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dict[1] = ("cat","Elvis")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dict[2] = ("dog","Barky")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt; len(dict) #how many keys?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; dict.keys() #dumps the keys out to a list&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[2,1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; "monkey" in dict #test for the existence of a certain key&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;False&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#print each key and it's 2nd associated value in the dictionary (2nd value is index 1)
for key in dict:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(key) + " - " + str(dict[key][1])&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;1 - Elvis&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2 - Barky&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179638#M13773</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T09:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179639#M13774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having some trouble getting this to work.&amp;nbsp; I'm getting a "'dict' object is not callable error when I use the simple code below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lutTbl = "New_Shapefile2"
targetTbl = "New_Shapefile"

lutDict = dict([(r[0], (r[1], r[2])) for r in arcpy.da.SearchCursor(lutTbl, ["ID","value","value2"])])
updateRows = arcpy.da.UpdateCursor(targetTbl, ["ID","value","value2"])
for updateRow in updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; joinFieldValue = updateRow[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[1] = updateRow[1] + lutDict[joinFieldValue][0] #assuming these values are numeric and not strings or anything!
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow[2] = updateRow[2] * lutDict[joinFieldValue][1] #assuming these values are numeric and not strings or anything!
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried lots of combinations of square brackets and paraentheses, but to no avail so far... is there some simple syntax i'm missing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I use my actual code (which has far more fields, so I'll spare the confusion) I'm actually getting a "can't concatenate 'str' and 'int' objects error.&amp;nbsp; This error does NOT have to do with my field type, but&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179639#M13774</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2021-12-11T09:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179640#M13775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm.... I might have missed a bracket or something in my example.... Here's an "real" example that I know works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;slopeDict = dict([(r[0], (r[1], r[2], int(r[3] + .5))) for r in arcpy.da.SearchCursor(slopePctZoneStatTbl, ["VALUE","MIN","MAX","MEAN"])])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another way to write this without so many confounded ([])()([[]]) symbols:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;slopeDict = {}
searchRows = arcpy.da.SearchCursor(slopePctZoneStatTbl, ["VALUE","MIN","MAX","MEAN"])
for searchRow in searchRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; keyValue = searchRow[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; minValue = searchRow[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; maxValue = searchRow[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; meanValue = int(searchRow[3] + .5)
&amp;nbsp;&amp;nbsp;&amp;nbsp; slopeDict[keyValue] = (minValue, maxValue, meanValue)
del searchRow, searchRows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;BTW: This assumes that your key values are all unique (I should have said that up front).&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for your concatenation issue, this illustration might help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print "hello" + 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print "hello" + str(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"hello1"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print int("1") + float("1.1")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print "hello" + "-" + str(1.1234)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;hello-1.1234&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179640#M13775</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T09:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179641#M13776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, thanks, I'll keep digging and will surely find the problem at some point.&amp;nbsp; Thanks for posting the alternate syntax -- it is definitely much easier to read.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 19:59:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179641#M13776</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-01T19:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179642#M13777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I'm using this code in a couple places in my script.&amp;nbsp; I have it working successfully two of the times it is used, but two other times it is used, I keep getting an error.&amp;nbsp; I have been through the code character by character and there are no syntax errors -- what works in one place doesn't work in the other place.&amp;nbsp; The different instances of the code all use FCs that are derived from the same source FC -- a simple point layer (subsets are made from this source layer and I'm trying to "join" between these subsets)-- so all of the field types are identical between the occurrences where it is working and where it isn't working.&amp;nbsp; The only difference I can find between the occasions where it is working and where it isn't working is that where it is working there are the same number of records in the update and join tables (one record in each table).&amp;nbsp; Where it isn't working, the join table only has a few matches in the update table&amp;nbsp; (so this would be equivalent to joining and field calculating only on the selected records where ("joinTable.OBJECTID" is not null).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error I am given is&amp;nbsp; the "cannot concatenate 'str' and 'int' objects".&amp;nbsp; It is thrown whenever I try to access the join table dictionary with this line &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;updateRow[1] =&amp;nbsp; updateRow[1] + joinDict[joinFieldValue][0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or, in fact, any time I try to use: joinDict[joinFieldValue][0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;so even this throws the same concatenation error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.AddMessage(joinDict[joinFieldValue][0])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The joinFieldValue is successfully obtained from updateRow[0] and even if I hard code a joinvalue, like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.AddMessage(joinDict[4220][0])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the same error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I need to add a conditional in somehow so that it only tries to access the dictionary if there is a match (is 'none' being returned and being treated as a string?)&amp;nbsp; Is there something else I am missing?&amp;nbsp; Again, I am confident there are no syntax errors and I am not trying to actually concatenate ints and strings.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the continued support!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:26:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179642#M13777</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-02T11:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179643#M13778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not sure why you are getting that issue. It may be a case of nulls coming across as an empty string. You can get around this by simply adding int() around each argument when you make your calculations. You could alternatively use float() if there are decimal numbers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;updateRow[1] =&amp;nbsp; int(updateRow[1]) + int(joinDict[joinFieldValue][0])&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 13:56:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179643#M13778</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-05-02T13:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179644#M13779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, Matthew, but no luck.&amp;nbsp; The problem occurs before I even try to make a calculation.&amp;nbsp; So even just this line throws the str/int error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.AddMessage(joinDict[joinFieldValue][0])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Adding in int here didn't help (nor would I expect it to).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.AddMessage(int(joinDict[joinFieldValue][0]))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, "joinFieldValue" is correctly populating with the join key (which happens to be an int).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll keep circling the problem... thanks for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 14:25:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179644#M13779</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-02T14:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179645#M13780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you print out a line of your dict showing the key and values?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 14:32:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179645#M13780</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-05-02T14:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179646#M13781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's a line of it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;{4931: (1466.31859047, 0.7298187853203999, 0.181307540288, 0.0, 0.0, 0.0, 0.0, 0.0, 1.45650000000222, 280800.0, 266454.070051103, 0, 3, 2524.95936472164, 312.0, 1303.0, 214200.0, 72900.0, 0)}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 14:35:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179646#M13781</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-02T14:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179647#M13782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Here's a line of it:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;{4931: (1466.31859047, 0.7298187853203999, 0.181307540288, 0.0, 0.0, 0.0, 0.0, 0.0, 1.45650000000222, 280800.0, 266454.070051103, 0, 3, 2524.95936472164, 312.0, 1303.0, 214200.0, 72900.0, 0)}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that there is only ever 1 key/value pair in the "join" dictionary at a time.&amp;nbsp; In one case where I'm having problems, there is only one record (of many) that it will join to in the "update" table.&amp;nbsp; I still cannot get this working.&amp;nbsp; Later, there is another instance where there are potentially &amp;gt;1 records that the single "join" key would join to.&amp;nbsp; Will cross that bridge when I get to it...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 14:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179647#M13782</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-02T14:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179648#M13783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could try str() for your print messages though that shouldn't be an issue. Do you get this for any record in your dict or does it only pop up after a while?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 14:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179648#M13783</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-05-02T14:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.UpdateCursor on joined tables?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179649#M13784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Every value in the dict throws the same error... can't get it to work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 14:57:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-updatecursor-on-joined-tables/m-p/179649#M13784</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2013-05-02T14:57:01Z</dc:date>
    </item>
  </channel>
</rss>

