<?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: Field Calculator- Delete last 3 text characters in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310844#M10748</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If there is always a space between first 3/4 characters and last 3 characters you can split the string and take the first part:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
"BN14 5RY".split()[0]
 
# or
 
"BN1 5RY".split()[0]
 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:52:00 GMT</pubDate>
    <dc:creator>NobbirAhmed</dc:creator>
    <dc:date>2021-12-11T14:52:00Z</dc:date>
    <item>
      <title>Field Calculator- Delete last 3 text characters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310838#M10742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have postcodes which I need to cut down from say BN14 5RY to only BN14. I cannot simply use the 'left(input, n)' equation as some postcodes are only 6 figures long such as BN1 5RY and I always need the first 3/4 characters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know a way to delete the last 3 characters?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Oct 2011 11:56:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310838#M10742</guid>
      <dc:creator>RobertLea</dc:creator>
      <dc:date>2011-10-16T11:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator- Delete last 3 text characters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310839#M10743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I have postcodes which I need to cut down from say BN14 5RY to only BN14. I cannot simply use the 'left(input, n)' equation as some postcodes are only 6 figures long such as BN1 5RY and I always need the first 3/4 characters.&lt;BR /&gt;&lt;BR /&gt;Does anyone know a way to delete the last 3 characters?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use the left() function if you combine it with the len() function.&amp;nbsp; This will do what you want (I assumed you also want to get rid of the space character and not just the last three non-whitespace characters):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;left(input, len(input) - 4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rtrim(left(input, len(input) - 3))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The len() function is normally used in combination with the left(), mid() and right() functions to control starting points, ending points and number of character values when doing string parsing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Oct 2011 14:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310839#M10743</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2011-10-16T14:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator- Delete last 3 text characters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310840#M10744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just in case you ever need to use the field calculation in a Python script, to do the same thing in Python you would also use the len() function.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;!input![len(!input!)-4]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rstrip(!input![len(!input!)-3])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Keep in mind that whitespace characters count, so in your examples "BN14 5RY" is 8 characters long, not 7 and "BN1 5RY" is 7 characters long, not 6.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Oct 2011 14:50:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310840#M10744</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2011-10-16T14:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator- Delete last 3 text characters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310841#M10745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great thank you for all that information. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes I made sure to delete the white space first and I was able to use the len() funtion with Left() to get the postcodes trimmed to the level I needed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Oct 2011 14:59:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310841#M10745</guid>
      <dc:creator>RobertLea</dc:creator>
      <dc:date>2011-10-16T14:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator- Delete last 3 text characters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310842#M10746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If your field contains string/text data, there is no need for the len method in Python since string data is an "iterable".&amp;nbsp; For example&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "abcdefghijklmnop"
&amp;gt;&amp;gt;&amp;gt; b = a[:-4]
&amp;gt;&amp;gt;&amp;gt; b
'abcdefghijkl'
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:51:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310842#M10746</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T14:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator- Delete last 3 text characters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310843#M10747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If your field contains string/text data, there is no need for the len method in Python since string data is an "iterable".&amp;nbsp; For example&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "abcdefghijklmnop"
&amp;gt;&amp;gt;&amp;gt; b = a[:-4]
&amp;gt;&amp;gt;&amp;gt; b
'abcdefghijkl'
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not really a Python programmer and my expression above would not work anyway because I didn't notice (in my quick check of some Python websites) that I needed the colon to indicate to take everything from the beginning of the string to the second position.&amp;nbsp; Thanks for correcting my Python ignorance and showing another example of where Python is more elegant than VB Script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310843#M10747</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T14:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator- Delete last 3 text characters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310844#M10748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If there is always a space between first 3/4 characters and last 3 characters you can split the string and take the first part:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
"BN14 5RY".split()[0]
 
# or
 
"BN1 5RY".split()[0]
 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:52:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculator-delete-last-3-text-characters/m-p/310844#M10748</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2021-12-11T14:52:00Z</dc:date>
    </item>
  </channel>
</rss>

