HOW TO
In ArcGIS Pro, it is sometimes necessary to remove extra spaces from the values of a string field in an attribute table. This can be achieved using the strip() Python function, which removes any characters, including spaces. This article describes the workflow to remove spaces using the strip() Python function in the Calculate Field tool.
In this example, the extra spaces from the values of the COUNTY field are removed to uniformize the format.
Note: • The strip() function removes all leading and trailing characters mentioned in the argument. If no argument is presented, only spaces are removed. • To remove either leading or trailing spaces, use the lstrip() or rstrip() functions respectively. • This function only works on string and text fields, not integer fields.
!Field Name!.strip()
Note: The Calculate Field tool changes the input data permanently. To enable undo, toggle the Enable Undo option on in the Calculate Field window before running the tool. Or, create a new field and configure the field.
The spaces are removed from the values in the COUNTY field.
Get help from ArcGIS experts
Download the Esri Support App