Python receipt in Calculate window

3598
2
06-08-2015 12:02 PM
D__SamuelRajasekhar
New Contributor III

In Field calculator window I would check Python and String

"CAMGMT15" + str(!FID!)

What if I want to add say FIDs from 1 to 250,000 and I want it to be CAMGMT1500000001, ....  ,CAMGMT1500002346 so forth.

Eight spaces from CAMGMT15 and f

Thanks

0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi D,

You could use the following expression:

"CAMGMT" + str(1500000000 + !FID!)

D__SamuelRajasekhar
New Contributor III

Hello Jake,

Thanks for the answer. Awesome, such a short time. I used the below function and it seemed to work:

"CAMGMT15" + str( !FID!).zfill(6)

The trick seems to be zfill. And if I add too many letters in the first string say "CAMMGMTSQ15" and set the zfill value at 8, I am getting error. Obviously the 15 length I set for this field is exceeded. 

0 Kudos