AnsweredAssumed Answered

Strip attributes of entire table

Question asked by 2CQuiker on Dec 29, 2015
Latest reply on Jan 4, 2016 by CCweedcontrol

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 =

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.TableToTable_conversion("parAdmin", "C:\Temp" , "ParAdmin_Test.dbf")

    print '(Elapsed time: ' + str( - startTime)[:-3] + ')'

except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message