1

I am currently attempting to use an update cursor from the data access module to update the PPCVal field based on a certain a set of conditional logic rules that I've laid out below. I've included the structure of my table so you can see the field names:

[![enter image description here][1]][1]

I've pasted a screenshot of my code below:

[![enter image description here][2]][2]

The code executes without any exceptions or errors but it appears it is not executing correctly on my second "elif" conditional where features that have WATER_FLAG = Z where index 3 (PPCVal) should be equal to index 1 (PPC_LOW).

You can see in my first screenshot of the table that the PPCVal field (index 3) is not updating correctly with the PPC_LOW value when WATER_FLAG = Z.

import arcpy, os

arcpy.env.workspace = r'C:/Capstone/Vermont1.gdb'
arcpy.env.overwriteOutput = True

fc = 'C:/Capstone/Vermont1.gdb/VT_PTS2_Intersect3'
fields = ['WATER', 'PPC_LOW', 'PPC_HIGH', 'PPCVal', 'WATER_FLAG']

with arcpy.da.UpdateCursor(fc, fields) as cursor:
    for row in cursor:
    #Evaluate WATER field for 'Y' and apply value from PPC_LOW (index 1)
    #to PPCVal
    if (row[0] == 'Y'):
        row[3] = row[1]
    #Evaluate WATER field for blank ' '  and apply value from PPC_HIGH
    # (index 2) to PPCVal
    elif (row[0] == ' '):
        row[3] == row[2]
    #Evaluate WATER_FLAG field for 'Z' (hauled water) and apply value from
    # PPC_LOW (index 1) to PPCVal
    elif (row[4] == 'Z'):
        row[3] = row[1]
    #Otherwise PPCVal = PPC_High (index 2)
    else:
        row[3] = row[2]

    cursor.updateRow(row)

print "PPCVal update finished."

closed as off-topic by Vince, user2856, Evil Genius, MaryBeth, whyzar Oct 13 '17 at 13:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – Vince, user2856, Evil Genius, MaryBeth, whyzar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Your screenshots does not work. Also you need to indentent all if statements after "for row in cursor" one more level and you need to remove one = sign in "row[3] == row[2]" – BERA Oct 13 '17 at 4:58
4

You have:

row[3] == row[2]

when it should be:

row[3] = row[2]

The former evaluates to False whereas the latter sets a variable value.

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