Hi, I wrote a few lines of Python code to add a set of fields if they are not already present in a feature layer. Here is my code. # Import modules
import arcpy
input_table = "myFeatureLayer"
# Input fields to create if they are not present in the feature layer
input_fields = ["a", "b", "c", "d", "e", "f", "g"]
# Field type
attr_type = "SHORT"
for field in input_fields:
if len(arcpy.ListFields(input_table, wild_card=field)) == 0:
arcpy.AddField_management(input_table, field_name = field, field_type = attr_type) Sometimes it runs through the first 3 fields on the list before raising an error and sometimes it only goes through 1 or 2 fields. There are couple of times when the whole code ran without issue and created the entire list of fields. This is the error I get: Runtime error Traceback (most recent call last): File "<string>", line 13, in <module> File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 3246, in AddField raise e ExecuteError: ERROR 999999: Error executing function. Failed to execute (AddField). Any suggestions or thoughts on what the issue might be? Thanks, Theja
... View more