I have a table that is generated else where. the problem i have is that the majority of the field attributes have different amount of spaces before and after the attribute. for example "____Blackhawk Sub No 1 _______". I have been manual using field calculator doing the !myfield!.lstrip, !myfield!.rstrip !myfield!.strip for each field and that sucks.
Is there a why to strip all the spaces infron/begining and at the end?
This table has both number and string.
I have been trying with the code below but i get an error on line 11. so i am thinking my expression is incorrect?
ERROR 000622: Failed to execute (Calculate Field). Parameters are not valid.
import arcpy from datetime import datetime as d startTime = d.now() arcpy.MakeTableView_management("C:\Temp\ParAdminTable.dbf", "parAdmin") for field in arcpy.ListFields("parAdmin", "*", "String"): sqlFieldName = arcpy.AddFieldDelimiters("parAdmin", field) calcSql= "' '.join( field.strip().split())" arcpy.CalculateField_management("parAdmin",field,calcSql,"PYTHON_9.3","#") arcpy.TableToTable_conversion("parAdmin", "C:\Temp" , "ParAdmin_Test.dbf") try: print '(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')' except Exception, e: # If an error occurred, print line number and error message import traceback, sys tb = sys.exc_info() print "Line %i" % tb.tb_lineno print e.message