MLCouden

AddField Failed to Execute???

Discussion created by MLCouden on Apr 30, 2013
Latest reply on May 2, 2013 by MLCouden
I am trying to join 2 fields in one layer which is a shapefile and join 2 fields in another layer which is a gdb. I think I have the coding right but it is not wanting to add my join field in my shapefile. It gives me a failed to execute AddField on the first one which is the shapefile. Any hints as to what might be wrong??

import arcpy, traceback
from arcpy import env

mxd = arcpy.mapping.MapDocument("CURRENT")

# Join Fields
fc = 'K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\Traffic_Count_Data\2011_Counts\2011_Annual_Stations\Annual_Stations_2011.shp'
env.workspace = 'K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\Traffic_Count_Data\District_Labels_Folder\Abilene_Labels.gdb'

fields_to_join = ['!F2011_TRAF!', '!FLAG!']
arcpy.AddField_management(fc, 'COUNT', 'TEXT')
arcpy.CalculateField_management(fc, 'COUNT', ''.join(fields_to_join), 'PYTHON')

fields_to_join = ['!TextString!', '!TFLAG!']
arcpy.AddField_management(inFeatures, 'TRAFFIC', 'TEXT')
arcpy.CalculateField-management(inFeatures, 'TRAFFIC', ''.join(fields_to_join), 'PYTHON')

lstLayers = arcpy.mapping.ListLayers(mxd)

Outcomes