1

I'm using a dictionary created by a search cursor from one feature class to update another feature class with an update cursor. I'm getting an invalid syntax error for the cursor.updateRow(row) and..have no idea why.

There must be something blatant I'm missing, yet I am simply not seeing it. Can someone point out why this code snippet would be providing an invalid syntax error for cursor.updateRow(row)? The format, from what I see, matches all the examples I've found.

    with arcpy.da.UpdateCursor(testingSHP, ['SERVICEMXL','STREETADDR']) as cursor:
        for row in cursor:
            mxLoc = row[0]
            oldAddr = row[1]
            if mxLoc in svcDict:
                print("Looking at row {0} with an address of {1}.".format(mxLoc, row[1]))
                row[1] = svcDict(mxLoc)
                print("Address is now {0}.".format(row[1])
                cursor.updateRow(row)
    del cursor
1
  • You're missing a closing parenthesis - change print("Address is now {0}.".format(row[1]) to print("Address is now {0}.".format(row[1])) – user2856 May 23 '20 at 3:17
2

I think you need to change: row[1] = scvDict(mxLoc) to row[1] = scvDict[mxLoc]

Also, oldAddr is currently unused, which is fine, but you could change this line to use it. print("Looking at row {0} with an address of {1}.".format(mxLoc, oldAddr))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.