AnsweredAssumed Answered

cursor compare last und actual row

Question asked by stadtlandfluss on Sep 10, 2015
Latest reply on Sep 11, 2015 by stadtlandfluss

How can I iterate trough a cursor an compare the last row with the actual?

 

def disolveOemDolungen(bnum):

    unterlieger = None

    pCursor = arcpy.UpdateCursor(oemFC, "BNUM = '" + bnum + "'","","von; bis; klasse, key","von A; bis A")

    row = pCursor.next()

    while row:

        if not unterlieger is None:

            if (unterlieger.getValue("klasse") == 7):

                arcpy.AddMessage("Oberlieger:" + unterlieger.getValue("key"))

                if (math.fabs(unterlieger.getValue("bis") - row.getValue("von")) <= 1):

                    unterlieger.setValue("klasse", row.getValue("klasse"))

                    unterlieger.setValue("sbreite", row.getValue("sbreite"))

                    pCursor.updateRow(unterlieger)

                    arcpy.AddMessage("Dissolve mit Oberlieger: " + unterlieger.getValue("key"))

        if row.getValue("klasse") == 7:

            if not unterlieger is None:

                arcpy.AddMessage("Unterlieger " + row.getValue("key"))

                if (math.fabs(unterlieger.getValue("bis") - row.getValue("von")) <= 1):

                    row.setValue("klasse", unterlieger.getValue("klasse"))

                    row.setValue("sbreite", unterlieger.getValue("sbreite"))

                    pCursor.updateRow(row)

                    arcpy.AddMessage("Dissolve mit Unterlieger: " + row.getValue("key"))

        unterlieger = row

        row = pCursor.next()

 

 

 

Row and unterlieger contains always the same Object. Therefore I can't compare the rows. How can this be done with Python?

Outcomes