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 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 first 5 numbers.
Here's background on what one can do with labeling:
As for your specific request, in VB Script I believe one would employ a RIGHT function and in Python one would use SLICING.
Right Function VB Script
Chris Donohue, GISP
The trouble with conversions is whether the conditions are already met. In your case you indicate a slicing off of the first 5 positions. This implies that
Python examples, since they tend to be simple to understand ...
>>> a = 3001522708 >>> str(a)[5:] '22708' >>> int(str(a)[5:]) 22708
line 1 your input is a number
line 2 conversion to string is required for slicing, and keep only the 'positions' after the 5th
line 3 the result is a conversion of type to string with the first 5 removed
line 4 assuming that the original numeric format is needed, this needs to be returned to integer
line 5 the result after conversion to string, slicing, conversion back
An example of an exception and what to do, can get complex,
>>> int(str(a)[5:]) if len(str(a))>5 else -999 -999
So attention to the small details is important.
Not sure if you got this figured out, but this is one way.
this will label with the last 5 digits of the numeric field as long as there are 5 or more digits. If less than 5, it will just label with however many it can get.
>>> a = 3001522708 >>> str(a)[-5:] '22708' >>> a = 1234 >>> str(a)[-5:] '1234' >>>