I am using 10.0 ArcView and am trying to get the "R" in R12345678910 to drop.
The numbers are in a column in the attribute table and i've always used VB scripting.
I was using Field Calculator.
-
3Where is this R12345678910 at? A field value in an attribute table? In the middle of a script? Field Calculator? Do you want a Python only solution? Some more details may yield more answers.Baltok– Baltok2012年12月11日 20:52:25 +00:00Commented Dec 11, 2012 at 20:52
-
Do all the values in your field have the same number of characters and/or number values? Also, do all the values begin with R?Baltok– Baltok2012年12月11日 21:15:28 +00:00Commented Dec 11, 2012 at 21:15
-
yes on both. R3415160838 is an example, same number of characters and the "R" in front of all.Zoran– Zoran2012年12月11日 21:20:10 +00:00Commented Dec 11, 2012 at 21:20
2 Answers 2
>>>'R12345678910'[1:]
'12345678910'
Appending [1:]
to a string in python will remove the initial character. Look up slice in the python help.
To use this in the ArcGIS field calculator, you will need to turn on Python parsing
for the unitCode =
enter
!your_field_name![1:]
-
[1: ] did not work - "there was a failure during processing, check the geoprocessing results window for details"Zoran– Zoran2012年12月11日 20:49:18 +00:00Commented Dec 11, 2012 at 20:49
VBScript Example:
Right( [FieldName], 11 )
This code will take the 11 characters from the right, and anything left of those 11 characters is omitted.
Python Example:
!FieldName!.lstrip('R')
This code takes a string and removes R from the left/front of it.
Both of these examples should get rid of the R in your strings.
Edit: Regan Sarwas' updated answer works great and is actually more versatile because it can handle more cases.
Explore related questions
See similar questions with these tags.