<?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: Remove duplicate text within an attribute of a feature class in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626922#M96867</link>
    <description>&lt;P&gt;related, this code block may work&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/td-p/1574012" target="_blank" rel="noopener"&gt;Splitting numbers and removing duplicates in a text string&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Or for a numpy def&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import numpy as np
def dedup(vals):
    """remove duplicate entries"""
    u = np.unique([i.strip() for i in vals.split(",")])
    return ", ".join([i for i in u])&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 25 Jun 2025 21:43:54 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2025-06-25T21:43:54Z</dc:date>
    <item>
      <title>Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626919#M96866</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an feature class with a field of concatenated&amp;nbsp; species_codes. I would like to remove the duplicate values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TinaKwitkoski_0-1750885748795.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/135102i8635FD259AB5D554/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TinaKwitkoski_0-1750885748795.png" alt="TinaKwitkoski_0-1750885748795.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would like to have just one label for each species. ie: AO, BB, BMC, CC, CH....&lt;/P&gt;&lt;P&gt;is there a way to do this?&lt;/P&gt;&lt;P&gt;Any help appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tina&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 21:11:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626919#M96866</guid>
      <dc:creator>TinaKwitkoski</dc:creator>
      <dc:date>2025-06-25T21:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626922#M96867</link>
      <description>&lt;P&gt;related, this code block may work&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/td-p/1574012" target="_blank" rel="noopener"&gt;Splitting numbers and removing duplicates in a text string&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Or for a numpy def&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import numpy as np
def dedup(vals):
    """remove duplicate entries"""
    u = np.unique([i.strip() for i in vals.split(",")])
    return ", ".join([i for i in u])&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 25 Jun 2025 21:43:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626922#M96867</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-06-25T21:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626927#M96868</link>
      <description>&lt;P&gt;Piece of cake; I just did this operation on some data this morning.&lt;/P&gt;&lt;P&gt;Here's some code for Field Calculator:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;A. Function Call&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;RemoveDupes(!AC!)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;B. Code Block&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def RemoveDupes(old):
    # Watch out for NULL values, because they'll crash the rest of the code
    if old is None:
        return None

    # If you're still here, assume it's a comma-delimited string, and break
    #   it up into parts.
    oldEntries = old.split(',')
    newEntries = []

    # Loop through the entries
    for entry in oldEntries:
        # Only save the entry if you haven't seen it already
        if entry not in newEntries:
            newEntries.append(entry)

    # Stitch the entries back to a string &amp;amp; write it to the field
    return ','.join(newEntries)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Results for the first row:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ANODON,BB,BMC,C,CAS,CC,CH,DC,DV,KO,L,LDC,LNC,LSU,MARFAL,MW,NSC,PK,RB,RSC,SP,SU,WF&lt;/LI-CODE&gt;&lt;P&gt;This could also be done via an UpdateCursor if you're doing other things, but I gave you Field Calculator first, for the simpler option.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Also, for those familiar with python: I&amp;nbsp;&lt;EM&gt;could&lt;/EM&gt; have used a set for newEntries, and it would've taken care of skipping the duplicates automatically.&amp;nbsp; But sets in python are unordered, which means the order would scramble when you ran this.&amp;nbsp; The longer approach of the code above arbitrarily maintains whatever order the entries occur in the field.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 16:12:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626927#M96868</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2025-06-26T16:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626929#M96869</link>
      <description>&lt;P&gt;Bonus solution for anyone with a similar case that wants to keep/display the duplicate entries, but wants a slightly easier-to-read value in the attribute table:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def CountDupes(old):
    if old is None:
        return None

    oldEntries = old.split(',')
    newEntries = {}

    for entry in oldEntries:
        if entry not in newEntries:
            newEntries[entry] = 0
        newEntries[entry] += 1

    return ','.join([f'{entry}:{count}' for entry, count in newEntries.items()]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Run on the sample data from the original post, this would be the result in the first row:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ANODON:1,BB:3,BMC:2,C:1,CAS:1,CC:3,CCG:1,CH:2,DC:2,DV:1,KO:2,L:1,LDC:1,LNC:1,LSU:1,MARFAL:1,MW:2,NSC:2,PK:1,RB:1,RSC:3,SP:1,SU:2,WF:1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even cleaner, would be displaying it without the singles:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def CountDupes(old):
    if old is None:
        return None

    oldEntries = old.split(',')
    newEntries = {}
    strEntries = []

    for entry in oldEntries:
        if entry not in newEntries:
            newEntries[entry] = 0
        newEntries[entry] += 1

    for entry, count in newEntries.items():
        if count == 1:
            strEntries.append(entry)
        else:
            strEntries.append(f'{entry}:{count}')&lt;/LI-CODE&gt;&lt;P&gt;And results:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ANODON,BB:3,BMC:2,C,CAS,CC:3,CCG,CH:2,DC:2,DV,KO:2,L,LDC,LNC,LSU,MARFAL,MW:2,NSC:2,PK,RB,RSC:3,SP,SU:2,WF&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 21:41:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626929#M96869</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2025-06-25T21:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626945#M96870</link>
      <description>&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 22:02:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626945#M96870</guid>
      <dc:creator>TinaKwitkoski</dc:creator>
      <dc:date>2025-06-25T22:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626946#M96871</link>
      <description>&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 22:03:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626946#M96871</guid>
      <dc:creator>TinaKwitkoski</dc:creator>
      <dc:date>2025-06-25T22:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626965#M96875</link>
      <description>&lt;P&gt;Very efficient; love it!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 23:02:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626965#M96875</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2025-06-25T23:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626995#M96877</link>
      <description>&lt;LI-CODE lang="python"&gt;import numpy as np
def dedup(vals):
    """remove duplicate entries"""
    u, cnts = np.unique([i.strip() for i in vals.split(",")], return_counts=True)
    v = np.vstack((u, cnts)).T
    return ", ".join(["{}: {}".format(i[0], i[1]) for i in v])
    
b ='AO, BB, BMC, CC, CH, AO, BB, BMC, CC, CH'
dedup(b)
'AO: 2, BB: 2, BMC: 2, CC: 2, CH: 2'&lt;/LI-CODE&gt;&lt;P&gt;This can be simplified, but verbose demonstrates the principle&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 00:10:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1626995#M96877</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-06-26T00:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1627216#M96882</link>
      <description>&lt;P&gt;Since counting the number of species codes wasn't stated as a requirement, this can be done much simpler without having to use a code block.&amp;nbsp; For the expression:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;",".join(sorted(set(!field!.split(',')))) if !field! is not None else None&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Jun 2025 14:07:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1627216#M96882</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-06-26T14:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate text within an attribute of a feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1627304#M96885</link>
      <description>&lt;P&gt;Worth noting: That one-liner presumes that alphanumeric sorting is the desired order.&lt;/P&gt;&lt;P&gt;The example data &lt;EM&gt;is&lt;/EM&gt;&amp;nbsp;all alphabetical, but there's insufficient information to predict whether that's presumable or just coincidental.&lt;/P&gt;&lt;P&gt;By avoiding casting to a set, whatever order each value appears in the field is maintained, sans duplicate entries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Also, the version that counts instances was just a fun 2-second self-challenge, more for the benefit of people landing on this page from a search in the future.)&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 16:10:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/remove-duplicate-text-within-an-attribute-of-a/m-p/1627304#M96885</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2025-06-26T16:10:14Z</dc:date>
    </item>
  </channel>
</rss>

