1

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 11, 2012 at 20:39
3
  • 3
    Where 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. Commented 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? Commented Dec 11, 2012 at 21:15
  • yes on both. R3415160838 is an example, same number of characters and the "R" in front of all. Commented Dec 11, 2012 at 21:20

2 Answers 2

8
 >>>'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:]
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Dec 11, 2012 at 20:44
1
  • [1: ] did not work - "there was a failure during processing, check the geoprocessing results window for details" Commented Dec 11, 2012 at 20:49
4

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.

answered Dec 11, 2012 at 21:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.