In ArcGIS Pro 2.2.4, I have a file geodatabase feature table where the ZIP code was imported as a long named "ZIP." I need it to be a string to 1) preserve leading zeroes and 2) join with another table on the ZIP field.
I opened the attribute table and added a new field called "ZIPText" of type String. I open Calculate Field and using Python 3, try to define ZIPText as !ZIP!.asString()
The expression validates, but when I run it, I get
ERROR 000539 File "<expression>", line 1
with the carat pointing at the "g" at the end of asString.
I've tried other expressions, but my Python is of the "google and try it variety" and Google's out of options.
Solved! Go to Solution.
Since ZIPs are currently stored as long, there won't be any leading zeroes to preserve. If you want to create them, you can use Python string formatting: