joelzao

Better way to do an UpdateCursor on several fields??

Discussion created by joelzao on Aug 1, 2012
Latest reply on Aug 2, 2012 by joelzao
Hello - I am trying to query a field(type-double) called "STATUS" and where there are "0's in that field, I want to update another field called "HAZ_STATUS"(type-text). So this might not be the best method, not sure, but it works. My question is, if I had to do this for another 15 fields, would I have to insert this code 15 times, or is there a better method? Also, I would update "STATUS" directly, but the field type is "double", and I want to update it with "text". So creating a new field with a new field type is the only solution, right?

I appreciate any comments - I'm pretty new at this..

fldName6 = "HAZ_STATUS"
inFeatures = os.getcwd() + '\\''myMDB.mdb\\myFC'
query = '[STATUS] = 0'
rows = arcpy.UpdateCursor(inFeatures, query)
row = rows.next()
while row:
    row.setValue(fldName6, "No Violations")
    rows.UpdateRow(row)
    row = rows.next()
del row, rows

Outcomes