<?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: Split a label over several lines, using commas, in python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689615#M53422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works beautifully, thanks for your assistance everyone &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/laugh.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 May 2016 22:22:06 GMT</pubDate>
    <dc:creator>BenVan_Kesteren1</dc:creator>
    <dc:date>2016-05-25T22:22:06Z</dc:date>
    <item>
      <title>Split a label over several lines, using commas, in python</title>
      <link>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689610#M53417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying my hand at using python to modify my labeling to suit. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a column which contains peoples names, this column can contain between one and four names, all separated by a comma. See sample data here:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/201989_pastedImage_3.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently when I label based on this column it looks pretty boring, what I would like is to split the names onto a new line, based on the comma. So essentially I want to find the comma, and insert a new line with the next name on it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what it currently looks like, and the code:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="696" src="https://community.esri.com/legacyfs/online/201955_pastedImage_2.png" style="width: 732px; height: 695.4px;" width="732" /&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel ([BENVA.%Burial_Data.NAM], [SDE_SPATIAL.GISADMIN.waugh_road_graves.GIS_Authority_Link]&amp;nbsp;&amp;nbsp; ):
&amp;nbsp; na = [BENVA.%Burial_Data.NAM]
&amp;nbsp; if na is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp; na = [SDE_SPATIAL.GISADMIN.waugh_road_graves.GIS_Authority_Link]
&amp;nbsp; return na&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any sample code they could provide that would achieve this? Alternatively give me some guidance as to how one would go about this???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much everyone.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:01:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689610#M53417</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2021-12-12T05:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Split a label over several lines, using commas, in python</title>
      <link>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689611#M53418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try something like this&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; na = "Fred, Charlie, Neil"
&amp;gt;&amp;gt;&amp;gt; print na.replace(",", "\n")
Fred
 Charlie
 Neil&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:01:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689611#M53418</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-12T05:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Split a label over several lines, using commas, in python</title>
      <link>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689612#M53419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just use the replace function to replace the commas with line breaks&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important;"&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important;"&gt; FindLabel ([BENVA.%Burial_Data.NAM], [SDE_SPATIAL.GISADMIN.waugh_road_graves.GIS_Authority_Link]&amp;nbsp; ):&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; na = [BENVA.%Burial_Data.NAM]&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important;"&gt;&amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important;"&gt; na &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important;"&gt;is&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important;"&gt; &lt;/SPAN&gt;&lt;SPAN class="special" style="font-weight: inherit; font-style: inherit; font-size: 9pt !important;"&gt;None&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important;"&gt;:&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; na = [SDE_SPATIAL.GISADMIN.waugh_road_graves.GIS_Authority_Link]&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important;"&gt;&amp;nbsp; return&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important;"&gt; na.replace (",", "\n")&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:01:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689612#M53419</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-12T05:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Split a label over several lines, using commas, in python</title>
      <link>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689613#M53420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since users have a bad habit of adding extra whitespace either before or after commas, I typically use a strategy of splitting, stripping, and rejoining the string so the stacked labels line up nicely.&amp;nbsp; Borrowing from &lt;A href="https://community.esri.com/migrated-users/5327" target="_blank"&gt;Neil Ayres&lt;/A&gt;​'s example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; na = "Fred ,Charlie, Neil"
&amp;gt;&amp;gt;&amp;gt; na
'Fred ,Charlie, Neil'
&amp;gt;&amp;gt;&amp;gt; print na.replace(",", "\n")
Fred
Charlie
 Neil
&amp;gt;&amp;gt;&amp;gt; print "\n".join(s.strip() for s in na.split(","))
Fred
Charlie
Neil
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:01:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689613#M53420</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T05:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Split a label over several lines, using commas, in python</title>
      <link>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689614#M53421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua,&lt;/P&gt;&lt;P&gt;much better.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2016 14:14:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689614#M53421</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-05-25T14:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Split a label over several lines, using commas, in python</title>
      <link>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689615#M53422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works beautifully, thanks for your assistance everyone &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/laugh.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2016 22:22:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-a-label-over-several-lines-using-commas-in/m-p/689615#M53422</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2016-05-25T22:22:06Z</dc:date>
    </item>
  </channel>
</rss>

