UPDATE MULTIPLE ATTRIBUTE

1066
2
Jump to solution
07-19-2016 08:54 AM
CCWeedcontrol
Occasional Contributor III

I have a feature class with filed DXF_TEXT and FZONE_CODE i would like to search for certain attributes in the DXF_TEXT field and update the FZONE_CODE but i am not sure what the best was to do it. i have tried the following but i can only do one at a time.

I would like to add more to the if row[0]== "R32558011","R32747010", "R32842", "R32839":

How can i search for "R32558011","R32747010", "R32842", "R32839" and update those select FZONE_CODE to " " (blank)?

Thanks.

with arcpy.da.UpdateCursor("C:\TEMP\FZon2", ['DXF_TEXT', 'FZONE_CODE']) as cursor:

    for row in cursor:

        if row[0] == "R32558011": #"R32747010", "R32842", "R32839":

            row[1] = " "

            cursor.updateRow(row)

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

if row[0] in [ blah, another, something]:

    row[1] = " "

else:

    do something else

View solution in original post

2 Replies
DanPatterson_Retired
MVP Emeritus

if row[0] in [ blah, another, something]:

    row[1] = " "

else:

    do something else

AlexanderBrown5
Occasional Contributor II

This should update all of them at once.  You were close!

with arcpy.da.UpdateCursor(r"C:\TEMP\FZon2", ['DXF_TEXT','FZONE_CODE']) as cursor:
...     for row in cursor:
...         if row[0] == "R32558011" or row[0] == "R32747010" or row[0] == "R32842" or row[0] == "R32839":
...             row[1] = ''
...             cursor.updateRow(row)

Regards,

Alex