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.

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.
    – Baltok
    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
    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
    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:]
1
  • [1: ] did not work - "there was a failure during processing, check the geoprocessing results window for details"
    – Zoran
    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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.