I am looking for the Python function that will allow me to convert a field from a string to a integer in a new field. I do not want to write Python script. It appears that the proper Python function would be .int but it doesn't exist in my field calculator in ArcGIS 10. Please help!
Solved! Go to Solution.
>>> s = ["1" ,"2", "", "abc"]
>>> [int(i) if i and i.isdigit() else -9999 for i in s]
[1, 2, -9999, -9999]
can you test
[int(i) if i and i.isdigit() else -9999 for i in !FieldName!] or
( int(i) if i and i.isdigit() else -9999 for i in !FieldName! )
no arc* to text
So the INT function does not exist in 10.3 Enterprise edition. However, I have finally found that if you open the Field Calculator and double click the string field that you want to convert, then press string. If your new field is set to Integer, it will automatically convert. Thanks for the help!