<?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: Splitting numbers and removing duplicates in a text string in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574381#M91810</link>
    <description>&lt;P&gt;The following should work in the Calculate Field expression without having to define a code block:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;",".join(set(!fieldname!.split(",")))&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 10 Jan 2025 16:36:04 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2025-01-10T16:36:04Z</dc:date>
    <item>
      <title>Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574012#M91765</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;Some time ago people helped me with a similar issue where I wanted to split textual data in a string&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008011#M8229" target="_blank"&gt;https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008011#M8229&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I'm trying to do the same thing with figures relating to areas, but possibly because these are numeric they behave differently. Running the code on&amp;nbsp;285311,285311,11540,11540 gives me the answer&amp;nbsp;11540285311, where what I really want is&amp;nbsp;285311,&amp;nbsp;11540.&lt;/P&gt;&lt;P&gt;I'm sure there's a simple solution, but looking at the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm&lt;/A&gt;&amp;nbsp;hasn't helped.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 17:05:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574012#M91765</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2025-01-09T17:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574019#M91767</link>
      <description>&lt;P&gt;On a relate note, how would I go about running the previous code but without sorting by alphabetical order? I assume it's a case of removing a bit of code, but I'm not sure which.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 17:11:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574019#M91767</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2025-01-09T17:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574026#M91768</link>
      <description>&lt;P&gt;This code block function will preserve the original order:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def dedupe(item_str):
    cleaned = []
    for item in item_str.split(","):
        if item not in cleaned:
            cleaned.append(item)
    if len(cleaned):
        return ", ".join(cleaned)
    return ""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change the strings on lines 3, 7 &amp;amp; 8 as needed to fit your data.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 17:22:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574026#M91768</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-09T17:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574283#M91801</link>
      <description>&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Thanks for that, but I'm very much a novice when it comes to coding. When you say 'change the strings' I'm not quite sure what you mean. When I try to select the fields in Field Calculator, it puts them in the top bit and it doesn't work. Assuming the field I want to use this on is called 'Area', how would this look.&lt;/P&gt;&lt;P&gt;Sorry.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 09:38:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574283#M91801</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2025-01-10T09:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574379#M91809</link>
      <description>&lt;P&gt;To use the function, throw it in the "Code Block", then you can use this as your expression:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dedupe(!Area!)&lt;/FONT&gt;. When I said "change the strings" I meant you can replace things like &lt;FONT face="courier new,courier"&gt;","&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;""&lt;/FONT&gt; to make the function split and join the results differently.&lt;/P&gt;&lt;P&gt;For context: the calculator runs all of the Python code in the code block before doing anything else, then for every selected record the calculator:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Grabs every field that has a pair of exclamation marks (!Area! in our example).&lt;/LI&gt;&lt;LI&gt;Does any data conversions it has to (usually only relevant for date or geometry fields).&lt;/LI&gt;&lt;LI&gt;Converts the expression you gave it into its complete state.&lt;/LI&gt;&lt;LI&gt;Evaluates the expression.&lt;/LI&gt;&lt;LI&gt;Stores that result in the field you're calculating&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In our case, the expression will evaluate to &lt;FONT face="courier new,courier"&gt;dedupe(123.45)&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;dedupe(23.43)&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;dedupe(None)&lt;/FONT&gt; or whatever is in each record's Area attribute. Hope this helps you get a handle on how the field calculator runs.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 16:31:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574379#M91809</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-10T16:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574381#M91810</link>
      <description>&lt;P&gt;The following should work in the Calculate Field expression without having to define a code block:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;",".join(set(!fieldname!.split(",")))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 10 Jan 2025 16:36:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574381#M91810</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-01-10T16:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574385#M91811</link>
      <description>&lt;P&gt;Python sets are not guaranteed to preserve insertion order so this could break in a future version of Pro. But it should work as of Pro 3.4 and Python&amp;nbsp;&lt;SPAN&gt;3.11.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 16:43:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574385#M91811</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-10T16:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574395#M91814</link>
      <description>&lt;P&gt;True, but the OP never stated maintaining the order was a requirement.&amp;nbsp; If maintaining order is a requirement, the expression can be changed to use a dict constructor instead of a set.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;",".join({i:None for i in !fieldname!.split(",")}.keys())&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 10 Jan 2025 16:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574395#M91814</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-01-10T16:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574397#M91816</link>
      <description>&lt;P&gt;Dictionaries are also not guaranteed to preserve insertion order and &lt;FONT face="courier new,courier"&gt;OrderedDict&lt;/FONT&gt; requires a code block so this isn't saving much. Although an &lt;FONT face="courier new,courier"&gt;OrderedDict&lt;/FONT&gt; would probably handle lists with thousands of items a bit faster.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 16:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574397#M91816</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-10T16:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574404#M91817</link>
      <description>&lt;P&gt;That changed in Python 3.7:&amp;nbsp; &lt;A href="https://docs.python.org/3/whatsnew/3.7.html" target="_blank" rel="noopener"&gt;What’s New In Python 3.7 — Python 3.13.1 documentation&lt;/A&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Python data model improvements:&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;P&gt;the insertion-order preservation nature of &lt;A href="https://docs.python.org/3/library/stdtypes.html#typesmapping" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;dict&lt;/SPAN&gt;&lt;/A&gt; objects &lt;A href="https://mail.python.org/pipermail/python-dev/2017-December/151283.html" target="_blank" rel="noopener"&gt;has been declared&lt;/A&gt; to be an official part of the Python language spec.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 17:17:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574404#M91817</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-01-10T17:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574409#M91818</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;Thanks to you both. I've tried both techniques and they work.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 17:33:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574409#M91818</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2025-01-10T17:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574413#M91819</link>
      <description>&lt;P&gt;Dang, looks like I missed that note when they changed the implementation, good catch!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 17:37:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574413#M91819</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-01-10T17:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting numbers and removing duplicates in a text string</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574440#M91822</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/305095"&gt;@SimonCrutchley&lt;/a&gt;&amp;nbsp;, as an FYI, you can mark multiple responses as a solution if multiple responses work for you.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2025 18:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/splitting-numbers-and-removing-duplicates-in-a/m-p/1574440#M91822</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-01-10T18:23:25Z</dc:date>
    </item>
  </channel>
</rss>

