Select to view content in your preferred language

formatting data ??????of a field on 4 digits in field calculator ?

719
3
08-05-2011 07:22 AM
AudreyH
New Contributor
Hi,

I'm working with ArcGIS10.
I have a shapefile with a field containing values ??????ranging from 1 to 9000.
I would like to format the values ??????of this field so that all values ??????are coded on 4 digits like this:
    1 --> 0001
    2 --> 0002
    3 --> 0003
    .
    .
    350 --> 0350
    .
   9000 --> 9000

Any suggestions or ideas?

Thanks.
Tags (2)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus
0 Kudos
BruceNielsen
Frequent Contributor
x.zfill(4) will accomplish this for you. x must be a string value, so if your existing value is a number, it would be str(x).zfill(4).
0 Kudos
AudreyH
New Contributor
x.zfill(4) will accomplish this for you. x must be a string value, so if your existing value is a number, it would be str(x).zfill(4).


it works, thank you very much for your answer !
0 Kudos