Select to view content in your preferred language

Using Where_clause with UpdateCursor and SearchCursor

568
1
03-03-2011 12:38 AM
GraziaZulian
Emerging Contributor
Could you give me an example for using a Where_clause with UpdateCursor?I need to iterate for all features with the same code in a multipart FeatureClass.

Here is an example that  doesn???t work to me:
codici=[]
cur = arcpy.SearchCursor(data)
for feature in cur:
    cod = feature.HSMU
    codici.append(cod)
for i in range(len(codici)):
    cod = codici
    where_clause = "[HSMU] = "+codici

    upcur = arcpy.UpdateCursor(multidata,where_clause,'','','')
    for feature in upcur:
        n = arcpy.GetCount_management(multidata)


thanks
Tags (2)
0 Kudos
1 Reply
MathewCoyle
Honored Contributor
It seems this is incomplete code?  No imports not sure if something else that handles this is missing as well. Also the no indenting makes this block a little hard to read with all the for loops, for me anyways. And what specific error are you getting?

What I think you want is a getValue in there, something like...

cur = arcpy.SearchCursor(data)
feature = cur.next()
for feature in cur:
     cod= feature.getValue("HSMU")
     feature = cur.next()
0 Kudos