<?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: How do I apply Title Case to just a portion of a text field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549887#M42963</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Lucas has it right I'd say, I'd maybe do something like this. Essentially the same thing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;line = 'AKRON, OH 12345'
line_split = line.split(',')
final_line = '{0},{1}'.format(line_split[0].title(), line_split[1])
print final_line&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 23:47:36 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2021-12-11T23:47:36Z</dc:date>
    <item>
      <title>How do I apply Title Case to just a portion of a text field</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549885#M42961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have an address field in all caps and I want to convert just the city to title case.&amp;nbsp; So I currently have:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AKRON, OH 12345&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;BREA, CA 54321&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And I want to see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Akron, OH 12345&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Brea, CA 54321&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically I want to know how to convert just a portion of a string, in this case the portion before the comma.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 21:29:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549885#M42961</guid>
      <dc:creator>BobPerham</dc:creator>
      <dc:date>2013-03-14T21:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I apply Title Case to just a portion of a text field</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549886#M42962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There could be a more elegant way, but this should do the trick:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = 'AKRON, OH 12345'
&amp;gt;&amp;gt;&amp;gt; alist = a.split(",")
&amp;gt;&amp;gt;&amp;gt; city = alist[0].title()
&amp;gt;&amp;gt;&amp;gt; final = city + "," + alist[1]
&amp;gt;&amp;gt;&amp;gt; print final
Akron, OH 12345&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549886#M42962</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2021-12-11T23:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I apply Title Case to just a portion of a text field</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549887#M42963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Lucas has it right I'd say, I'd maybe do something like this. Essentially the same thing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;line = 'AKRON, OH 12345'
line_split = line.split(',')
final_line = '{0},{1}'.format(line_split[0].title(), line_split[1])
print final_line&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:47:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549887#M42963</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T23:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I apply Title Case to just a portion of a text field</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549888#M42964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm sorry.&amp;nbsp; Maybe I should have mentioned, I need to do this in the field calculator.&amp;nbsp; The field name is CITYSTATE.&amp;nbsp; So normally I would just enter !CITYSTATE!.title() and it would Title Case the whole value.&amp;nbsp; Do I need to check off "Show Codeblock" and add it as pre-script logic?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 22:32:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549888#M42964</guid>
      <dc:creator>BobPerham</dc:creator>
      <dc:date>2013-03-14T22:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I apply Title Case to just a portion of a text field</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549889#M42965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can integrate either of these into the field calculator. Select to use Python for the parser, and check to Show Codeblock.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression should be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;title(!fieldName!)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def title(name): &amp;nbsp; alist = name.split(",") &amp;nbsp; city = alist[0].title() &amp;nbsp; final = city + "," + alist[1] &amp;nbsp; return final&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 22:56:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-apply-title-case-to-just-a-portion-of-a/m-p/549889#M42965</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-14T22:56:31Z</dc:date>
    </item>
  </channel>
</rss>

