<?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 Fields by Matching Fields in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186192#M14327</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked perfect. I only need to modify to only update features that have a RecID = 0 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used this and added code to generate a zipfile.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Oct 2017 22:12:47 GMT</pubDate>
    <dc:creator>DevinUnderwood2</dc:creator>
    <dc:date>2017-10-12T22:12:47Z</dc:date>
    <item>
      <title>Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186186#M14321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to know what is the best way via arcpy&amp;nbsp; to update a feature field&amp;nbsp;by referencing another features field.&lt;/P&gt;&lt;P&gt;I don't know if it is possible to use a updatecursor for 2 different features.&lt;/P&gt;&lt;P&gt;Would I just perform a temporary join and use arcpy like field calculator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Example of my cursor attempt.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;searchcursor &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"BASE.ROADS_SG_ESC"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
updatecursor &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"escroads"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; searchcursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; RD20NAME &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getValue&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"RD20NAME"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; updatecursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getValue&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"NAME"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; RD20NAME&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updatecursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:26:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186186#M14321</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-11T09:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186187#M14322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you could join, then update a field... you could do this with cursors, but most people ignore simple field calculations can be accessed through the &lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field.htm"&gt;&lt;STRONG&gt;Calculate Field tool&lt;/STRONG&gt; &lt;/A&gt;and its associated script code at the bottom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Oct 2017 22:57:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186187#M14322</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-10-10T22:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186188#M14323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For starters, look into using the Data Access (&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/what-is-the-data-access-module-.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/what-is-the-data-access-module-.htm"&gt;What is the data access module?—Help | ArcGIS Desktop&lt;/A&gt; ) cursors instead of the original/old cursors.&amp;nbsp; The DA cursors perform much better and are a bit more Pythonic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code snippet confuses me more than helps me understand what you are trying to do.&amp;nbsp; Code aside, what are you trying to do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 02:37:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186188#M14323</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-10-11T02:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186189#M14324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will look&amp;nbsp; into the Data Access module as an alternative to old cursors.&lt;/P&gt;&lt;P&gt;Good advice on Calculate field tool and a join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will see what works for me. As I am trying to copy attributes from one field of a feature class to another feature class.&lt;/P&gt;&lt;P&gt;However, I need to match the feature classes fields that have different field names. All of this done via a python script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 14:11:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186189#M14324</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-10-11T14:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186190#M14325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a code i use for similar situations.&lt;/P&gt;&lt;P&gt;You need to have a uniqueID for both features layers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;from time import strftime&amp;nbsp; 
print "Start script: " + strftime("%Y-%m-%d %H:%M:%S")&amp;nbsp; 
import arcpy

#Transfer of Multiple Field Values between Feature Classes where there is a 1:1 Match between Field Sets
&amp;nbsp; 
sourceFC = "Parcels"

#change OID@ to your uniqueID 
sourceFieldsList = ['OID@', 'Field_1','Field_2', 'Field_3','Field_4']&amp;nbsp; # Your Source fields&amp;nbsp; 
&amp;nbsp; 
# Use list comprehension to build a dictionary from a da SearchCursor&amp;nbsp; 
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}&amp;nbsp; 
&amp;nbsp; 
updateFC = "Points"&amp;nbsp; 
&amp;nbsp; 
updateFieldsList = ['OID@', 'Field1', 'Field2', 'Field3', 'Field4']&amp;nbsp; # your updateFC fields
&amp;nbsp; 
with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for updateRow in updateRows:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # store the Join value of the row being updated in a keyValue variable&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; keyValue = updateRow[0]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # verify that the keyValue is in the Dictionary&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if keyValue in valueDict:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # transfer the values stored under the keyValue from the dictionary to the updated fields.&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for n in range (1,len(sourceFieldsList)):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow&lt;N&gt; = valueDict[keyValue][n-1]&amp;nbsp; 
&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)&amp;nbsp; 
&amp;nbsp; 
del valueDict&amp;nbsp; 
&amp;nbsp; 
print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S")&amp;nbsp; 
print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S")
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/N&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:26:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186190#M14325</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-11T09:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186191#M14326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, I will try this out.&amp;nbsp; My unique will be roadsegid&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 19:57:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186191#M14326</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-10-11T19:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186192#M14327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked perfect. I only need to modify to only update features that have a RecID = 0 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used this and added code to generate a zipfile.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Oct 2017 22:12:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186192#M14327</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-10-12T22:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186193#M14328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post your modified code please.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Oct 2017 20:55:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186193#M14328</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2017-10-16T20:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186194#M14329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to post it after I modify the code some more to use ListFields rather than manually hardcode the field names.&lt;/P&gt;&lt;P&gt;Also, one last section of tying in the max() value to the auto increment () function, which I haven't had a chance to test yet, but soon.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Oct 2017 21:36:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186194#M14329</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-10-16T21:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Update Fields by Matching Fields</title>
      <link>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186195#M14330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible to modify this script so that a source field and an update field could have different field types if the values are the still the same?&amp;nbsp; For example if my source and update fields have a value of '1234', but the source field is an integer and the update field is a string, can they still be used with list comprehension somehow? Or would it be better to just add a corresponding field with the matching field type to my update layer?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2019 20:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-fields-by-matching-fields/m-p/186195#M14330</guid>
      <dc:creator>ChadBunn1</dc:creator>
      <dc:date>2019-01-30T20:20:04Z</dc:date>
    </item>
  </channel>
</rss>

