<?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 Identify duplicate records &amp;amp;amp; increment in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/identify-duplicate-records-amp-amp-increment/m-p/667657#M51841</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey GIS Users,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to identify duplicate records from a field and then change these records so they become unique by assigning at the end &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;of text string A,B,C, or 1,2,3 (eg F3241 A56_A or F3241 A56_1).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to make the change in the field the records are stored in and not create another field. Also, I'm looking to perform this &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;as part of a bigger function using modelbuilder so would like to use field calculator or a python script so I can place it in the model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached a screenshot of the field &amp;amp; records I'm trying to identify &amp;amp; increment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any input into to this would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Sep 2012 05:40:01 GMT</pubDate>
    <dc:creator>ChrisGraves</dc:creator>
    <dc:date>2012-09-24T05:40:01Z</dc:date>
    <item>
      <title>Identify duplicate records &amp;amp; increment</title>
      <link>https://community.esri.com/t5/python-questions/identify-duplicate-records-amp-amp-increment/m-p/667657#M51841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey GIS Users,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to identify duplicate records from a field and then change these records so they become unique by assigning at the end &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;of text string A,B,C, or 1,2,3 (eg F3241 A56_A or F3241 A56_1).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to make the change in the field the records are stored in and not create another field. Also, I'm looking to perform this &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;as part of a bigger function using modelbuilder so would like to use field calculator or a python script so I can place it in the model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached a screenshot of the field &amp;amp; records I'm trying to identify &amp;amp; increment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any input into to this would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 05:40:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/identify-duplicate-records-amp-amp-increment/m-p/667657#M51841</guid>
      <dc:creator>ChrisGraves</dc:creator>
      <dc:date>2012-09-24T05:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Identify duplicate records &amp; increment</title>
      <link>https://community.esri.com/t5/python-questions/identify-duplicate-records-amp-amp-increment/m-p/667658#M51842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I thing create dictionary with increment value would be simple and elegant solution. It will look something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import sys
in_table = sys.argv[1]
field = sys.argv[2]

val_dict = {}

cur = arcpy.UpdateCursor(in_table)
for row in cur:
&amp;nbsp; value = row.getValue(field)
&amp;nbsp; if value not in val_dict.keys():
&amp;nbsp;&amp;nbsp;&amp;nbsp; val_dict[value] = 0
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; val_dict[value] += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(field, value + '_' + str(val_dict[value]))
&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.updateRow(row)
del cur
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/identify-duplicate-records-amp-amp-increment/m-p/667658#M51842</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2021-12-12T04:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Identify duplicate records &amp; increment</title>
      <link>https://community.esri.com/t5/python-questions/identify-duplicate-records-amp-amp-increment/m-p/667659#M51843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great thank you Arek that has done the trick &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 10:50:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/identify-duplicate-records-amp-amp-increment/m-p/667659#M51843</guid>
      <dc:creator>ChrisGraves</dc:creator>
      <dc:date>2012-09-27T10:50:48Z</dc:date>
    </item>
  </channel>
</rss>

