<?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: Copy values from one field to another from duplicate record in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/copy-values-from-one-field-to-another-from/m-p/1226350#M65963</link>
    <description>&lt;P&gt;I would make 2 passes through the table. First with a search cursor to find and record the duplicates, second with an update cursor to update the two fields as needed.&amp;nbsp; Something like this......&lt;/P&gt;&lt;LI-CODE lang="c"&gt;addrkey_to_streets = dict()
with arcpy.da.SearchCursor(table, ['ADDR_KEY', 'CROSS_ST_NAMES']) as cursor:   
    for addrkey, street in cursor:
        if addrkey not in addrkey_to_streets.keys():
            addrkey_to_streets[addrkey] = {'first': street, 'second': None}
        else:
            addrkey_to_streets[addrkey]['second'] = street

with arcpy.da.UpdateCursor(table, ['ADDR_KEY', 'CS1StreetName', 'CS2StreetName']) as cursor:
    for addrkey, cs1_street, cs2_street in cursor:
        cursor.updateRow([addrkey, addrkey_to_streets[addrkey]['first'], addrkey_to_streets[addrkey]['second']])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Oct 2022 19:28:51 GMT</pubDate>
    <dc:creator>DonMorrison1</dc:creator>
    <dc:date>2022-10-27T19:28:51Z</dc:date>
    <item>
      <title>Copy values from one field to another from duplicate record</title>
      <link>https://community.esri.com/t5/python-questions/copy-values-from-one-field-to-another-from/m-p/1226300#M65961</link>
      <description>&lt;P&gt;I have a point feature class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this screenshot you will see that ADDR_KEY contains duplicate values. I want to move the values in CROSS_ST_NAMES field to CS1StreetName field and CS2StreetName field as follows:&lt;/P&gt;&lt;P&gt;ADDR_KEY = 3460 (1st occurrence) then move CROSS_ST_NAMES to CS1StreetName&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[the value that would be placed in CS1StreetName field would be GABLE DR/MCDUFF AVE]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then ADDR_KEY = 3460 (2nd occurrence) then move CROSS_ST_NAMES to CS2StreetName&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[the value that would be placed in CS2StreetName field would be FUSTERIA CT/MCDUFF AVE]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;and so on for the other ADDR_KEY values...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any ideas how to do this in python or with a geoprocessing tool? I am new to python.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CrossStreetScreenshot.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54635iEE20648CBA2AC1A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="CrossStreetScreenshot.PNG" alt="CrossStreetScreenshot.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 18:27:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-values-from-one-field-to-another-from/m-p/1226300#M65961</guid>
      <dc:creator>TimHayes3</dc:creator>
      <dc:date>2022-10-27T18:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Copy values from one field to another from duplicate record</title>
      <link>https://community.esri.com/t5/python-questions/copy-values-from-one-field-to-another-from/m-p/1226350#M65963</link>
      <description>&lt;P&gt;I would make 2 passes through the table. First with a search cursor to find and record the duplicates, second with an update cursor to update the two fields as needed.&amp;nbsp; Something like this......&lt;/P&gt;&lt;LI-CODE lang="c"&gt;addrkey_to_streets = dict()
with arcpy.da.SearchCursor(table, ['ADDR_KEY', 'CROSS_ST_NAMES']) as cursor:   
    for addrkey, street in cursor:
        if addrkey not in addrkey_to_streets.keys():
            addrkey_to_streets[addrkey] = {'first': street, 'second': None}
        else:
            addrkey_to_streets[addrkey]['second'] = street

with arcpy.da.UpdateCursor(table, ['ADDR_KEY', 'CS1StreetName', 'CS2StreetName']) as cursor:
    for addrkey, cs1_street, cs2_street in cursor:
        cursor.updateRow([addrkey, addrkey_to_streets[addrkey]['first'], addrkey_to_streets[addrkey]['second']])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 19:28:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copy-values-from-one-field-to-another-from/m-p/1226350#M65963</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-10-27T19:28:51Z</dc:date>
    </item>
  </channel>
</rss>

