If I have a field say 'account' and I want all the white space (if there is any to the right and left of the account entry, for example 83128313 - is there a python script or field calculator function that can do this for me?
You are looking for the str.strip() method:
Calculate your field to be:
This will remove all the whitespaces both to the left and to the right.
s = ' 83128313 '
would result after:
With ArcPy you would do the following:
import arcpy with arcpy.da.UpdateCursor(r'pathToYourDataset',['theField']) as cursor: for row in cursor: row = row.strip() cursor.updateRow(row)
All you have to do is replace theField with the name of the field you want to update, and pathToYourDataset with the path to your dataset, such as:
with arcpy.da.UpdateCursor(r"D:\PythonTesting\randomData\City.shp",['spatialID']) as cursor: