TransWikia.com

Using ArcPy Update Cursor with ArcMap

Geographic Information Systems Asked on April 22, 2021

I am trying to do an update cursor in my script. Can someone please tell me why when I do 2 IF statements only the second IF statement runs.

For example this runs fine

fc = CAD_WA
fields = ["LAND_TYPE", "LAND_NAME", "LOTNO", "LotNo_F" ]

# Create update cursor for feature class
with arcpy.da.UpdateCursor(fc, fields) as cursor:

    for row in cursor:

        if row[0] == "RESVE":
            row[3] = row[1]

            cursor.updateRow(row)

But if I do this expression only the second if statment runs. Why?

fc = CAD_WA
fields = ["LAND_TYPE", "LAND_NAME", "LOTNO", "LotNo_F" ]

# Create update cursor for feature class
with arcpy.da.UpdateCursor(fc, fields) as cursor:

    for row in cursor:

        if row[0] == "RESVE":
            row[3] = row[1]
        if row[1] == "UCL":
            row[3] = row[1]

            cursor.updateRow(row)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP