I am trying to add 2 (multiple) fields to each feature class in a gdb. I based the script off of Python Script to Add Fields to Feature Classes.
I feel like I am missing something and can't figure it out.
import arcpy, os
arcpy.env.workspace = r'Z:\project\....gdb'
for fc in arcpy.ListFeatureClasses():
try:
arcpy.AddField_management(fc, "Depth", "SHORT", field_length = 10)
arcpy.AddField_management(fc, "OD", "SHORT", field_length = 10)
with arcpy.da.UpdateCursor(fc, "Depth", "OD") as cursor:
for row in cursor:
row[0] = fc
cursor.updateRow(row)
print "Working on {0}".format(fc)
except Exception as ex:
print "There was an error ---> {0}".format(ex)
print ("Add Field Finished")