<?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: Using Python to Split Address Field in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35436#M1978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wouldn't this return unwanted results if the street name started with CIR? For example: W CIRCLE VIEW DR&lt;/P&gt;&lt;P&gt;I'm doing something similar and I use &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;A href="https://docs.python.org/2/library/stdtypes.html#str.rpartition" rel="nofollow noopener noreferrer" target="_blank"&gt;str.rpartition()&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;head, sep, tail = st_name.rpartition(" CIR")
if tail == '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; return head‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If the tail partition string is empty, you know there is nothing else after the separator and it's safe to return the head.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;Also tagging &lt;A href="https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=08a40ef2-e9bb-4c41-a843-b13ab3d6c973&amp;amp;searchIndex=0" target="_blank"&gt;https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=08a40ef2-e9bb-4c41-a843-b13ab3d6c973&amp;amp;searchIndex=0&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 21:22:55 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-12-10T21:22:55Z</dc:date>
    <item>
      <title>Using Python to Split Address Field</title>
      <link>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35432#M1974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using Python in the Field Calculator to split an address field and I cannot find the string function I need for my function. Basically, what I want to do is create a function to say if 'CIR' is in the string name return everything before 'CIR', but not 'CIR'. I am just trying to get the street name, not the street type in the field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def street_name (st_name):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if ' CIR' in st_name:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot find a string function to return everything to the left of 'CIR'. Thank in advance everyone.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 19:59:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35432#M1974</guid>
      <dc:creator>MatthewUpchurch1</dc:creator>
      <dc:date>2016-10-28T19:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to Split Address Field</title>
      <link>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35433#M1975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matthew, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; street_name &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;st_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' CIR'&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; st_name&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; st_name&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;' CIR'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; name&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:22:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35433#M1975</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T21:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to Split Address Field</title>
      <link>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35434#M1976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As a start, I don't have an exact answer for you, but a suggestion to try.&amp;nbsp; I was thinking you could use Replace, but put "" instead of what was used (see thread):&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/120808"&gt;Python - using Replace in Field Calculator&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That said, I'm sure some of the experienced Python folks have a more elegant solution, so I'm curious to see what they come up with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/Dan_Patterson"&gt;Dan_Patterson&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/19932"&gt;Darren Wiens&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris Donohue, GISP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 20:07:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35434#M1976</guid>
      <dc:creator>ChrisDonohue__GISP</dc:creator>
      <dc:date>2016-10-28T20:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to Split Address Field</title>
      <link>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35435#M1977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's what I was looking for &lt;A href="https://community.esri.com/people/jskinner-esristaff"&gt;jskinner-esristaff&lt;/A&gt;, I just needed to declare a variable and use the .split() function. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 20:14:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35435#M1977</guid>
      <dc:creator>MatthewUpchurch1</dc:creator>
      <dc:date>2016-10-28T20:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to Split Address Field</title>
      <link>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35436#M1978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wouldn't this return unwanted results if the street name started with CIR? For example: W CIRCLE VIEW DR&lt;/P&gt;&lt;P&gt;I'm doing something similar and I use &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;A href="https://docs.python.org/2/library/stdtypes.html#str.rpartition" rel="nofollow noopener noreferrer" target="_blank"&gt;str.rpartition()&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;head, sep, tail = st_name.rpartition(" CIR")
if tail == '':
&amp;nbsp;&amp;nbsp;&amp;nbsp; return head‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If the tail partition string is empty, you know there is nothing else after the separator and it's safe to return the head.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;Also tagging &lt;A href="https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=08a40ef2-e9bb-4c41-a843-b13ab3d6c973&amp;amp;searchIndex=0" target="_blank"&gt;https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=08a40ef2-e9bb-4c41-a843-b13ab3d6c973&amp;amp;searchIndex=0&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:22:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-python-to-split-address-field/m-p/35436#M1978</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-10T21:22:55Z</dc:date>
    </item>
  </channel>
</rss>

