Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an 11 digit ID in one field I'll call "Current_ID". I would like to create a new field named "New_Field" and populate it with same value except I need to change the value of the 4th digit from a 5 to a 4.

Example: 
"Current_ID" = 1505000001
"New_Field" desired ID =  1504000001

Both field types are Double

400 records

How can this be done using Field Calc?

share|improve this question
2  
You really should be using a Long instead of a Double field for storing IDs... – nmpeterson Mar 23 at 20:58
up vote 5 down vote accepted

Use field calculator expression:

"Current_ID"-1000000
share|improve this answer

If you're always only changing the fourth digit to a 4 - In field calculator on the New_Field select Python parser, and input the following:

int('{}4{}'.format(str( !Current_ID! )[:3], str( !Current_ID! )[4:]))

This will replace the fourth digit with a 4 (whatever that fourth digit may be).

If it needs to be a number other than 4, change the number in {}4{}

enter image description here

share|improve this answer

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.