Select to view content in your preferred language

UpdateCursor help

418
3
01-23-2019 09:02 AM
RyanPhillips2
Emerging Contributor

Hello,

I am having issues using the update cursor function. This is what I have written, I get no errors but it does nothing:

 

with arcpy.da.UpdateCursor("test1", ["SYM", "FLD_ZONE","Label", "ZONE_SUBTY"]) as rows:

...     for row in rows:

...        if row[3] == "" and row[1] in ["A", "AE", "AH", "AO", "VE"]:

...           row[0] = 100

...           row[2] = row[1]

...           rows.updateRow(row)

basically if row[3] is empty and row[1] has these " " , update these rows with this

0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

/blogs/dan_patterson/2016/08/14/script-formatting  so line numbers can be referred to  Ryan

if row[3] is None and row[1] in ["A", "AE", "AH", "AO", "VE"]:

assuming you don't have any spaces in row[3], in which case you would have to do another 'in' test for 

ie row[3] in [" ", None]

RyanPhillips2
Emerging Contributor

Hello Dan,

Thank you so much for replying so quickly. The code works however it is still not populating anything into the fields.

0 Kudos
DanPatterson_Retired
MVP Emeritus

["A", "AE", "AH", "AO", "VE"]  

are those the exact codes that are in there?

throw print statements in before the if statement to print out the contents of row[3] and row[1]