2

I would like to create an expression using the field calculator in ArcMap to be able to convert an Int field to a string and add leading zeroes.

I am able to do it in a python window with an example

x=450
print str(x).zfill(4)
>>>0450

I have tried:

!Time!.str().zfill(4)

but that gives me invalid syntax errors.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 12, 2015 at 20:03
1

1 Answer 1

5

str is a class, not a method, so you need to do:

str(!Time!).zfill(4)

This should work if the Time field is an integer. If it's a float or other type, you will need to recast it as an int.

answered Jan 12, 2015 at 20:22
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.