<?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 data in an attribute table in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007699#M8222</link>
    <description>&lt;P&gt;sure can... field calculator expression using python parser.&lt;/P&gt;&lt;P&gt;Now... how do you want the output formatted?&lt;/P&gt;&lt;P&gt;remove the duplicates?&lt;/P&gt;&lt;P&gt;sort the output?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# ---- split on splitter, remove duplicates and rejoin in sorted order 
def split_o_rama(a, splitter="/"):
    """split stuff, keeping first"""
    out = []
    sp = a.split(splitter)
    for i in sp:
        if i not in out:
            out.append(i)
    return splitter.join([i for i in sorted(out)])
    
# ---- sample data and run
a = "e/a/b/c/a/d/a/b"
split_o_rama(a)
'a/b/c/d/e'&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 08 Dec 2020 14:40:03 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2020-12-08T14:40:03Z</dc:date>
    <item>
      <title>Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007693#M8221</link>
      <description>&lt;P&gt;Is it possible to split data within a single field in an attribute table. I have been provided some data where one field currently consists of concatenated data from a table with multiple values separated by "/". There are numerous duplicate elements, which makes the field look messy, so I'd like to remove them. I've had success doing this by exporting into Excel and Word, but it's very long winded, and because of the size of the files very slow, so I wondered if it's possible actually working within GIS.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 14:23:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007693#M8221</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2020-12-08T14:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007699#M8222</link>
      <description>&lt;P&gt;sure can... field calculator expression using python parser.&lt;/P&gt;&lt;P&gt;Now... how do you want the output formatted?&lt;/P&gt;&lt;P&gt;remove the duplicates?&lt;/P&gt;&lt;P&gt;sort the output?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# ---- split on splitter, remove duplicates and rejoin in sorted order 
def split_o_rama(a, splitter="/"):
    """split stuff, keeping first"""
    out = []
    sp = a.split(splitter)
    for i in sp:
        if i not in out:
            out.append(i)
    return splitter.join([i for i in sorted(out)])
    
# ---- sample data and run
a = "e/a/b/c/a/d/a/b"
split_o_rama(a)
'a/b/c/d/e'&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Dec 2020 14:40:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007699#M8222</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-12-08T14:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007709#M8223</link>
      <description>&lt;P&gt;Since you seem new to Python, I will offer an alternative so you can see how one of Python's built-in data structures can help in situations like yours.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# ---- split on splitter, remove duplicates using set and rejoin in sorted order 
def set_o_rama(a, splitter="/"):
    """split stuff, keeping only one of each"""
    sp = set(a.split(splitter))
    return splitter.join(sorted(sp))

# ---- sample data and run
a = "e/a/b/c/a/d/a/b"
set_o_rama(a)
'a/b/c/d/e'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 15:09:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007709#M8223</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-12-08T15:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007720#M8224</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;Those both look like they will do exactly what I need. Unfortunately, I have no idea how to actually apply them. Do I just copy that text into the Calculated field box or what?&lt;/P&gt;&lt;P&gt;Sorry&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 15:30:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007720#M8224</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2020-12-08T15:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007757#M8225</link>
      <description>&lt;P&gt;It is good to start with &lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field-examples.htm" target="_blank"&gt;Calculate Field Python examples—ArcGIS Pro | Documentation&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;An overview:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Open Field Calculator&lt;/LI&gt;&lt;LI&gt;Select Python 3 Expression Type:&lt;/LI&gt;&lt;LI&gt;Put the following in Expression Box (change &lt;EM&gt;field1&lt;/EM&gt; with your field)&lt;OL&gt;&lt;LI&gt;set_o_rama(!field1!)&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Put the function definition in Code Block&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 08 Dec 2020 16:47:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007757#M8225</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-12-08T16:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007758#M8226</link>
      <description>&lt;P&gt;Thanks. I'll give that a go tomorrow. I should add that I'm working in ArcMap, not ArcGIS Pro, but hopefully that should still work?&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 16:52:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007758#M8226</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2020-12-08T16:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007760#M8227</link>
      <description>&lt;P&gt;Field Calculator didn't change much between ArcMap and Pro, so you should be able to translate the information over.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 16:57:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007760#M8227</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-12-08T16:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007991#M8228</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;I tried that, but I'm getting an error message. I attach screenshots of the 'Calculated field' box, and the 'Geoprocessing result'.&lt;/P&gt;&lt;P&gt;I note that in the ArcPro documentation that 'legacy' (which I'm assuming includes ArcMap) uses Python and Python 9.3, not Python 3. Does this make a difference, or have I done something wrong in the code box?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 09:55:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1007991#M8228</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2020-12-09T09:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008011#M8229</link>
      <description>&lt;P&gt;Code block&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def set_o_rama(a, splitter="/"):
    """split stuff, keeping only one of each"""
    sp = set(a.split(splitter))
    return splitter.join(sorted(sp))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression box&lt;/P&gt;&lt;P&gt;set_o_rama(!YourFieldNameHere!)&amp;nbsp; # note the ! marks&lt;/P&gt;&lt;P&gt;It is best to select the field name from the dialog's provided list to ensure that the correct format is determined.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 12:05:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008011#M8229</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-12-09T12:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008017#M8230</link>
      <description>&lt;P&gt;Brilliant! I hadn't realised it sorts alphabetically, which confused me at first, but that's fine. The key fact is that it removes all the annoying duplicates.&lt;/P&gt;&lt;P&gt;Apologies that I misunderstood about all the different bits in the code and which need to be added and which don't.&lt;/P&gt;&lt;P&gt;Thanks so much. &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 12:42:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008017#M8230</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2020-12-09T12:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008018#M8231</link>
      <description>&lt;P&gt;Thanks for all your help with this.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 12:44:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1008018#M8231</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2020-12-09T12:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1058848#M8339</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;You were very helpful with the above last year, so I'm hoping that you can help again with a similar issue. Having concatenated the list so that it is searchable in a single attribute, I now discover that I need to make hyperlinks to the various entries &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;. The easiest way to do this seems to be to split them into separate entries and then do a link to each unique entry, as there are far too many different combinations. I assume that this is what the first part of your program did, so hope it's not difficult to then create a new field for each of the separate options e.g. the field TYPE 'ENCLOSURE/FIELD/FIELD SYSTEM/SETTLEMENT' becomes TYPE1 'ENCLOSURE', TYPE2 'FIELD', TYPE3 'FIELD SYSTEM' etc.&lt;/P&gt;&lt;P&gt;I hope you can help.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 08:56:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1058848#M8339</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2021-05-18T08:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1059972#M8340</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;are you requiring that you use the same idea, but place each parsed value into a separate field?&lt;/P&gt;&lt;P&gt;Maybe you could elaborate more on what the table and inputs should look like.&lt;/P&gt;</description>
      <pubDate>Thu, 20 May 2021 15:06:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1059972#M8340</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-05-20T15:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1059992#M8341</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;That's exactly it. As I show above, I currently have the concatenated fields, separated by / e.g. the field currently called 'TYPE' has entries such as&amp;nbsp;&lt;SPAN&gt;'ENCLOSURE/FIELD/FIELD SYSTEM/SETTLEMENT' and I would like this to become a number of separate new fields&amp;nbsp;TYPE1 = 'ENCLOSURE', TYPE2 = 'FIELD', TYPE3 = 'FIELD SYSTEM' etc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I attach a sample of a file where I did the split manually, to see if the process would produce the data in a form that I could then use in Portal, in a pop-up.&lt;/P&gt;&lt;P&gt;I hope that makes sense.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 20 May 2021 15:43:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1059992#M8341</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2021-05-20T15:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data in an attribute table</title>
      <link>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1064047#M8342</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;I was just wondering whether you'd had any further thoughts about this? Do you need further information from me?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 13:24:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/splitting-data-in-an-attribute-table/m-p/1064047#M8342</guid>
      <dc:creator>SimonCrutchley</dc:creator>
      <dc:date>2021-06-02T13:24:37Z</dc:date>
    </item>
  </channel>
</rss>

