I am trying to use the updateCursor but with little luck... What I would like to do is copy field values from an existing field in the table to a newly created field in the table. The issue I am having is that some tables have different name values and field types. I wonder if I am overcomplicating the whole issue or if I am setting something up incorrectly. I am just not sure at this point. Any insight and help with this will be greatly appreciated!
I am getting error 999999 on "return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args)))".
for filename in filenames:
if fnmatch.fnmatch(filename, "*Anno*") == True:
print "Skipped annotation file: " + filename
elif fnmatch.fnmatch(filename, "*grid*") == True:
print "Skipped grid file: " + filename
else:
#LOOP FIELDS
fieldList = arcpy.ListFields(os.path.join(dirpath, filename))
for field in add_Fields:
if field[0] in [f.name for f in fieldList]:
print "Field name: " + field[0] + " exists in " + filename + " DO NOT ADD"
else:
print "Adding " + field[0] + " name to table " + filename
arcpy.AddField_management(*(os.path.join(dirpath, filename),) + field)
#create field search list
possibleSearchFields = ["ENG_NAME", "Name"]
updateField = ["New_Name"]
searchFields = []
#Loop through possibleSearchFields
for psf in possibleSearchFields:
if psf in [f.name for f in fieldList]:
#add to searchFields
searchFields.append(psf)
#LOOP ROWS
cur = arcpy.UpdateCursor(os.path.join(dirpath, filename))
for row in cur:
for searchField in searchFields:
if row.getValue(updateField) == None:
print searchField + "exists in the table and is updating: " + filename
row.setValue(updateField, row.getValue(searchField))
else:
print " No name field in the search list: " + filename
Thank you
Chris