Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am using 10.0 ArcView and am trying to get the "R" in R12345678910 to drop. I lost all my scripts I've saved and appreciate some assistance.

The numbers are in a column in the attribute table and i've always used VB scripting. I was using Field Calculator.

share|improve this question
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 '12 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 '12 at 21:15
    
yes on both. R3415160838 is an example, same number of characters and the "R" in front of all. –  Zoran Dec 11 '12 at 21:20
add comment

2 Answers

up vote 6 down vote accepted
 >>>'R12345678910'[1:]
    '12345678910'

Edit 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:]
share|improve this answer
    
[1: ] did not work - "there was a failure during processing, check the geoprocessing results window for details" –  Zoran Dec 11 '12 at 20:49
    
perfect regan. thank you. –  Zoran Dec 12 '12 at 15:46
add comment

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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