I am running ArcMap 10.4.1. I am running a script that uses a DA search cursor nested inside an update cursor to assign variables from values in a table. The script then writes those same variables to a feature class in the update cursor. I have done this many times in the past, but now I am getting a tuple assignment error when I try to assign row values in the update cursor. I know tuples aren't mutable and I am not trying to assign values in the search cursor. What is the problem here? This syntax has worked many times in the past.
The script fails on the first attempted row assignment after the search cursor:
row[2] = tblAppAdd
TypeError: 'tuple' object does not support item assignment
Here is the script portion (edited for length):
with arcpy.da.UpdateCursor(u'lyr_patientsPts', fcFields) as fieldsCursor:
for row in fieldsCursor:
appID = unicode(row[1])
# This is a custom function I found to simplify writing SQL search statements
# for the where_clause in the search cursor.
tblWhere = WhereClauseFromList(tblPatients, u'APPLICATION_ID', [appID])
# Get values of the fields in the table to put into the points feature class
with arcpy.da.SearchCursor(tblPatients, tblFields, where_clause = tblWhere) as tblCursor:
for row in tblCursor:
tblAppAdd = unicode(row[2])
tblAppCity = unicode(row[3])
tblAppState = unicode(row[4])
# ... etc there are ten more fields
# Write values from table to points feature class
row[2] = tblAppAdd
row[3] = tblAppCity
row[4] = tblAppState
# etc
fieldsCursor.updateRow(row)
sRow
since you're already usingrow
for the UpdateCursor.