I have three text fields populated as follows: 1, 9, 1 that I need to concatenate into a field that looks like 01.09.01. Getting to 1.9.1 is easy but can anyone help out with how to formulate it so that each value has two places (i.e. add in those zeroes). I used to do this in Excel but can't figure out how to work in ArcMap 10.
|
"0"& [field1]&".0"& [field2] & ".0" & [field3] |
||||
|
Use the zfill() command in Python. Set your Field Calculator parser to Python, and do this:
|
|||
|
|
|
Generally, I do something like the following in Python, to pad with leading '0's to whatever length is needed:
|
|||||
|
|
Here is a simple Python function that right-justifies to the specified width each item in a sequence of items using
Example usage:
Field calculator expression (be sure to switch to the Python parser):
The str() conversion function is needed for each field reference in case there are any null values as the default field calculator behavior when a null is encountered is to stop execution and skip to the next row. |
||||
|
|
