AnsweredAssumed Answered

Field Caluclator Error

Question asked by rralbritton1981 on Mar 27, 2013
Latest reply on Mar 27, 2013 by curtvprice
I've written a script. that uses the field calculator to create a value for a new field, "TotGroupField". This field value is = to Field1+Field2+Field3....

I'm getting the following error:
Traceback (most recent call last):   File RCW\Code\", line 99, in <module>     GrpExpression = sum([GrpField1New+GrpField2New+GrpField3New+GrpField4New+GrpField5New]) TypeError: unsupported operand type(s) for +: 'int' and 'str'

#Create Feature Layers from Feature Classes parcelsFC = "ACUB_3mile.shp" parcelsFL = outName(parcelsFC,"_Layer") CbuffersFL = outName(CBuffersFC,"_Layer")  arcpy.MakeFeatureLayer_management(parcelsFC, parcelsFL) arcpy.MakeFeatureLayer_management(CBuffersFC, CbuffersFL)  TotalGrpField = "TotGrpCalc" #Temp - will be deleted TotalPBGField = "TotaBGCalc" #Temp - Will be deleted AvgGrpField= "AvgGrp0812" #Make into user input AvgPBGField= "AvgPBG0812" #Make into user input arcpy.AddField_management(CbuffersFL,TotalGrpField,"DOUBLE") print arcpy.GetMessages(),"\n" arcpy.AddField_management(CbuffersFL,TotalPBGField,"DOUBLE") print arcpy.GetMessages(),"\n" arcpy.AddField_management(CbuffersFL,AvgGrpField, "DOUBLE") print arcpy.GetMessages(),"\n" arcpy.AddField_management(CbuffersFL,AvgPBGField,"DOUBLE") print arcpy.GetMessages(),"\n"  #Join All Nest Files Table to new selected buffer file. This table was preproccessed and made into a single dbf table (joined by cluster key) showing groupsize and PBG by year. #A column was created called TotalSize and Total PGB for each cluster. The total column will be used to help calculate the average group size/average pbg size for RCW clusters #whose 3-mile dispersal buffer intersect with each parcel.  #This means this table will have to be updated manually every year unless written into the script. #This join is used to calculate criteria 2 and 3. #Input for a join must be a layer  NestFiles="/RCW/Nest Data/Edited Nest Data/Nest_All.dbf" arcpy.AddJoin_management(CbuffersFL,"Cluster_ke",NestFiles,"Key12","KEEP_ALL") print arcpy.GetMessages(),"\n"   GrpField1= "Nest_All.GrpSz08" #User selects field GrpField2= "Nest_All.GrpSz09" #User selects field GrpField3= "Nest_All.GrpSz10" #User selects field GrpField4= "Nest_All.GrpSz11" #User Selects field GrpField5= "Nest_All.GrpSz12" #User selects field GrpField1New= "!"+GrpField1+"!" GrpField2New= "!"+GrpField2+"!" GrpField3New= "!"+GrpField3+"!" GrpField4New= "!"+GrpField4+"!" GrpField5New= "!"+GrpField5+"!"  GrpExpression = sum([GrpField1New+GrpField2New+GrpField3New+GrpField4New+GrpField5New])    arcpy.CalculateField_management(CbuffersFL,TotalGrpField,GrpExpression,"PYTHON") print arcpy.GetMessages()