I'm using this code as a python script tool in ArcGIS 10.1:
import arcpy, os
arcpy.env.workspace = r'W:\S&P\s&p techs\Emily\Errors.gdb'
#Looping through dissolved feature classes, adding 'Name' field and writing
#feature class name in the added field.
fcs = arcpy.ListFeatureClasses()
for fc in fcs:
arcpy.AddField_management(fc, "Name", "TEXT", field_length = 50)
with arcpy.da.UpdateCursor(fc, "Name") as cursor:
for row in cursor:
row[0] = fc
cursor.updateRow(row)
All it's supposed to do is add a field to some feature classes in a database. I double checked that the path is right, so I don't think that's the problem. This code has also worked before, but for some reason it's not working anymore. I get an error that says this when I run it:
arcpy.da.UpdateCursor(fc, ["Name"])
fields list or tuple instead of string. – Surya Jan 22 at 19:22