<?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 text strings in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762746#M58930</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the quick response...However, I am still having problems with it.&amp;nbsp; This could be because I am pretty new to python but I threw this into the field calculator and it gave me the errors with geoprocessing message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(!ADDRESS!.split(" ")[0]) == 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This did not work for some reason.&amp;nbsp; Any other suggestions? For beginners? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Jul 2012 15:23:22 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-07-02T15:23:22Z</dc:date>
    <item>
      <title>Splitting text strings</title>
      <link>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762743#M58927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am working on an addressing project for my county and I am trying to split an address field from parcel data that we have.&amp;nbsp; I have been using the !Field!.split(" ")[0] function to split them by spaces.&amp;nbsp; The problem is I want to get street names that have 2 and 3 words to be separate from the N, S, E, and W prefixes and not all of the records in the field have the N or S before the street name so doing it by order of the spaces is not really going to work.&amp;nbsp; I am wondering if there is any sort of .length() type function to select only one letter parts of a record in a string (the N, S, E, or W) and put it into a field by itself so I know which addresses I need to populate the prefix for?&amp;nbsp; Or what is the best way to split fields when I have street names like Valley Forge Dr, N Main St, and King Ave?&amp;nbsp; I need the direction in one field, the street name in another (one and two word street names), and the suffix in the last field. I know to get just the suffix I can use the !Field!.split(" ")[-1], but is it possible to just get the prefix from the records that have one?&amp;nbsp; If anyone can help please let me know! Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GIS Technician&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cedar County, IA&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 12:39:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762743#M58927</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-07-02T12:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting text strings</title>
      <link>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762744#M58928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is indeed a length test:&amp;nbsp;&amp;nbsp; len()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if len(!Field!.split(" ")[0]) == 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp; you have a one letter prefix&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:25:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762744#M58928</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2021-12-12T08:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting text strings</title>
      <link>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762745#M58929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here are a couple functions you can use to get the prefix, street name, and suffix.&amp;nbsp; You would need to make some minor changes to get this to work in the field calculator.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def prefix(): &amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(table) &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(row.FullAddr.split(" ")[0]) == 1: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Prefix = row.FullAddr[0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row) &amp;nbsp;&amp;nbsp;&amp;nbsp; del row, rows&amp;nbsp; def suffix(): &amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(table) &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Suffix = row.FullAddr.split(" ")[-1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row) &amp;nbsp;&amp;nbsp;&amp;nbsp; del row, rows&amp;nbsp; def street(): &amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(table) &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(row.FullAddr.split(" ")[0]) == 1: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Street = ' '.join(row.FullAddr.split(" ")[1:-1]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Street = ' '.join(row.FullAddr.split(" ")[0:-1]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row) &amp;nbsp;&amp;nbsp;&amp;nbsp; del rows, row&amp;nbsp; prefix() suffix() street()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 15:15:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762745#M58929</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-07-02T15:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting text strings</title>
      <link>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762746#M58930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the quick response...However, I am still having problems with it.&amp;nbsp; This could be because I am pretty new to python but I threw this into the field calculator and it gave me the errors with geoprocessing message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(!ADDRESS!.split(" ")[0]) == 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This did not work for some reason.&amp;nbsp; Any other suggestions? For beginners? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 15:23:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762746#M58930</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-07-02T15:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting text strings</title>
      <link>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762747#M58931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;And thank you Jake, I just now saw your reply.&amp;nbsp; I will try this and see if I can get it to work.&amp;nbsp; I am no expert with python so I will see how much of this code I can understand and try to modify it to work.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 15:25:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762747#M58931</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-07-02T15:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting text strings</title>
      <link>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762748#M58932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for that update cursor!&amp;nbsp; It worked like a charm! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caleb&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 15:39:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/splitting-text-strings/m-p/762748#M58932</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-07-27T15:39:18Z</dc:date>
    </item>
  </channel>
</rss>

