<?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: Best Way to Shorten a Numeric Label in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265349#M20417</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The trouble with conversions is whether the conditions are already met. &amp;nbsp;In your case you indicate a slicing off of the first 5 positions. &amp;nbsp;This implies that&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;there will always be more than 5 characters&lt;/LI&gt;&lt;LI&gt;the returned result will be of the same form as the input&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Python examples, since they tend to be simple to understand ...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3001522708&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'22708'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&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;22708&lt;/SPAN&gt;&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;line 1 &amp;nbsp; your input is a number&lt;/P&gt;&lt;P&gt;line 2 &amp;nbsp; conversion to string is required for slicing, and&amp;nbsp;keep only the 'positions' after the 5th&lt;/P&gt;&lt;P&gt;line 3 &amp;nbsp; the result is a conversion of type to string with the first 5 removed&lt;/P&gt;&lt;P&gt;line 4 &amp;nbsp; assuming that the original numeric format is needed, this needs to be returned to integer&lt;/P&gt;&lt;P&gt;line 5 &amp;nbsp; the result after conversion to string, slicing, conversion back&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example of an exception and what to do, can get complex,&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;999&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;999&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&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;So attention to the small details is important.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:59:05 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-11T12:59:05Z</dc:date>
    <item>
      <title>Best Way to Shorten a Numeric Label</title>
      <link>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265347#M20415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not new to ArcMap, however I am in need of some help. I want to shorten a numeric label. Specifically I want to shorten&amp;nbsp;3001522708 to 22708. This data is tabulated into an attributes table, and is displayed easily by the labels tab in properties, however it is to long. I have already looked up other methods to shorten and/or change the labels using VBScript, Python, or JScript but I do not know the specific code to remove the&amp;nbsp;first 5 numbers.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2016 04:53:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265347#M20415</guid>
      <dc:creator>JarettBell</dc:creator>
      <dc:date>2016-10-14T04:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Shorten a Numeric Label</title>
      <link>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265348#M20416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's background on what one can do with labeling:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.3/map/working-with-text/about-building-label-expressions.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/map/working-with-text/about-building-label-expressions.htm"&gt;Building label expressions—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for your specific request, in &lt;EM&gt;VB Script&lt;/EM&gt; I believe one would employ a RIGHT function and in &lt;EM&gt;Python&lt;/EM&gt; one would use SLICING.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://msdn.microsoft.com/en-us/library/eh8fefz1(v=vs.84).aspx" title="https://msdn.microsoft.com/en-us/library/eh8fefz1(v=vs.84).aspx"&gt;Right Function&lt;/A&gt; VB Script&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pythoncentral.io/cutting-and-slicing-strings-in-python/" title="http://pythoncentral.io/cutting-and-slicing-strings-in-python/"&gt;Cutting and slicing strings in Python - Python Central&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, 14 Oct 2016 05:25:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265348#M20416</guid>
      <dc:creator>ChrisDonohue__GISP</dc:creator>
      <dc:date>2016-10-14T05:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Shorten a Numeric Label</title>
      <link>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265349#M20417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The trouble with conversions is whether the conditions are already met. &amp;nbsp;In your case you indicate a slicing off of the first 5 positions. &amp;nbsp;This implies that&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;there will always be more than 5 characters&lt;/LI&gt;&lt;LI&gt;the returned result will be of the same form as the input&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Python examples, since they tend to be simple to understand ...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3001522708&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'22708'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&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;22708&lt;/SPAN&gt;&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;line 1 &amp;nbsp; your input is a number&lt;/P&gt;&lt;P&gt;line 2 &amp;nbsp; conversion to string is required for slicing, and&amp;nbsp;keep only the 'positions' after the 5th&lt;/P&gt;&lt;P&gt;line 3 &amp;nbsp; the result is a conversion of type to string with the first 5 removed&lt;/P&gt;&lt;P&gt;line 4 &amp;nbsp; assuming that the original numeric format is needed, this needs to be returned to integer&lt;/P&gt;&lt;P&gt;line 5 &amp;nbsp; the result after conversion to string, slicing, conversion back&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example of an exception and what to do, can get complex,&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;999&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;999&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&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;So attention to the small details is important.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:59:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265349#M20417</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T12:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Shorten a Numeric Label</title>
      <link>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265350#M20418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if you got this figured out, but this is one way.&lt;/P&gt;&lt;P&gt;this will label with the last 5 digits of the numeric field as long as there are 5 or more digits.&amp;nbsp; If less than 5, it will just label with however many it can get.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/284264_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3001522708&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'22708'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1234&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'1234'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &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;/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>Sat, 11 Dec 2021 12:59:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265350#M20418</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-11T12:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Shorten a Numeric Label</title>
      <link>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265351#M20419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You shouldn't really mark your own thread helpful... it draws moderator attention as well as those that posted in the thread&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Dec 2016 00:54:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265351#M20419</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-12-16T00:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Shorten a Numeric Label</title>
      <link>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265352#M20420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, didn't realize I did that.&lt;/P&gt;&lt;P&gt;For that matter, didn't know that you could.&lt;/P&gt;&lt;P&gt;Apparently I can't "un-mark" it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Dec 2016 00:56:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-way-to-shorten-a-numeric-label/m-p/265352#M20420</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2016-12-16T00:56:28Z</dc:date>
    </item>
  </channel>
</rss>

