I have a table with two fields. One field (type short) is empty. One field (type string) is full of digits. There are no random characters in that field, just digits. I want to convert the string digits into integers and put them in the empty field.
How do I do this in the field calculator?
Figured it out. The strings of digits were 8 digits long. That would make an integer too large for a type short. I made a new field of type long and field calculator converted it easily.
-
You can just calc them equal to each other. The values should be cast automatically.Paul– Paul2018年06月13日 16:57:34 +00:00Commented Jun 13, 2018 at 16:57
2 Answers 2
Open field calculator on the blank column and set the parser to python
Find the existing (string) column header on the left panel and double click it to bring the field name into the code block. Then click ok, this will copy all values from the string column into the short type column.
-
Doesn't work. when I try that I get an error. The Results console says "The value type is incompatialbe with the field type"Bob Dole– Bob Dole2018年06月13日 17:23:16 +00:00Commented Jun 13, 2018 at 17:23
-
you said you had spaces in the original field? you can confirm all values are in fact integers with no string charactersNULL.Dude– NULL.Dude2018年06月13日 18:17:52 +00:00Commented Jun 13, 2018 at 18:17
String to Integer using Field calculator (VB Scribt)
As mentioned in ArcGIS Technical Support
You can convert the string field to integer by doing the following:
Right-click on your integer field>> Field calculator>> (VB Scribt) then just choose your string field from the fields box
=[FieldName]
Explore related questions
See similar questions with these tags.