<?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: Right Trim String after Special Char in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170899#M13136</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try !ADDRESS_GEO!.split(';')[0]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Feb 2011 18:52:13 GMT</pubDate>
    <dc:creator>ChrisMathers</dc:creator>
    <dc:date>2011-02-25T18:52:13Z</dc:date>
    <item>
      <title>Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170898#M13135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, so I know it's probably something really simple that I'm missing, but, I need some help getting this to work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got an attribute field !ADDRESS_GEO!.&amp;nbsp; This is a text field that has addresses in it, but they were user submitted addresses that include ";" and "#" type information.&amp;nbsp; An example address would be "123 W Main St ; STE 120" and "234 E Main St #D".&amp;nbsp; To geocode these using the geocode service I've got, I have to strip out the ";" and "#" characters as well as anything to the right of them and ideally leading and trailing spaces from the resulting string.&amp;nbsp; I'm using the Calculate Field geoprocessing tool in 9.3.1 Sp2.&amp;nbsp; I've tried a couple of expressions I thought would work to no avail, so, if anyone can help...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried the expressions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;!ADDRESS_GEO!.rstrip(';')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;!ADDRESS_GEO![:(!ADDRESS_GEO!.find(';'))]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it makes any difference, the error I'm getting is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"ERROR 000539: Error running expression: [:(.find(';'))] &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid syntax (&amp;lt;string&amp;gt;, line 1)"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 17:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170898#M13135</guid>
      <dc:creator>John_S</dc:creator>
      <dc:date>2011-02-25T17:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170899#M13136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try !ADDRESS_GEO!.split(';')[0]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 18:52:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170899#M13136</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-02-25T18:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170900#M13137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I Tried and got the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"ERROR 000539: Error running expression: .split(';')[0]&amp;nbsp; &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid syntax (&amp;lt;string&amp;gt;, line 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField)."&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 19:43:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170900#M13137</guid>
      <dc:creator>John_S</dc:creator>
      <dc:date>2011-02-25T19:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170901#M13138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Uhh I hate trying things like this in the calculator. Get the python window out and just use an update cursor. Try this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cursor=arcpy.UpdateCursor(yourFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.ADDRESS_GEO=row.ADDRESS_GEO.split(';')[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del cursor&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 20:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170901#M13138</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-02-25T20:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170902#M13139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm still in Desktop 9.3.1, does arcpy actually work in 9.3.1?&amp;nbsp; I thought that was only at 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If only I could use a simple update cursor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 20:15:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170902#M13139</guid>
      <dc:creator>John_S</dc:creator>
      <dc:date>2011-02-25T20:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170903#M13140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for all your suggestions and help.&amp;nbsp; I honestly have no earthly clue what was wrong with any of the above mentioned efforts to resolve the issue, but, I did manage to finally work out an "~ish" work-around that involved &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;export to Excel &amp;gt; text to columns tool &amp;gt; delete extra new columns &amp;gt; import Excel table into Database &amp;gt; create join based on ObjID (included in export to Excel) &amp;gt; calculate field in original table to match corrected field in joined table&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I really would still love to figure out some effective calculate expression to resolve this quickly all within the database (since I will have to do this somewhat regularly for a new project I got), but, I guess I may have to wait on that until I am allowed by my 3rd party extensions to upgrade to V10 so I can use arcpy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for the suggestions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 21:21:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170903#M13140</guid>
      <dc:creator>John_S</dc:creator>
      <dc:date>2011-02-25T21:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170904#M13141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;parser:&amp;nbsp; Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Prelogic code section&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def split_string(a_field):
&amp;nbsp; return a_field.split(";")[0]
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;expression section&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;split_string(!textfield!)&amp;nbsp; #where !textField! is the field you are trying to split&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:51:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170904#M13141</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T08:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Right Trim String after Special Char</title>
      <link>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170905#M13142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just to add on to this if anyone else stumbles across this thread trying to reverse concatenate a field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I needed a simplified way to trim/split address numbers from a string in Python in the field calculator.&amp;nbsp;&amp;nbsp; For example, for "199 MAIN ST"&amp;nbsp; I needed returned "MAIN ST".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Many ways to skin a cat but this can be done with an extension of the code provided above:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def split_string(a_field):
&amp;nbsp; return a_field.split(" ", 1)[1]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Codeblock:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;split_string(!MY_FIELD!)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:51:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/right-trim-string-after-special-char/m-p/170905#M13142</guid>
      <dc:creator>KennethBrevard</dc:creator>
      <dc:date>2021-12-11T08:51:40Z</dc:date>
    </item>
  </channel>
</rss>

