Skip to main content
added 260 characters in body
Source Link
Marc Pfister
  • 4.1k
  • 17
  • 11

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

for row1 in cursor1:    
    for row in cursor:      
        if row1.getValue(field) == row.getValue(field):
            if row1.getValue(maxfield) == row.getValue(field1):
                cursor2.insertRow(row)
    cursor.reset()

As it is written with the next() and no reset, it's going to do something like:

  1. Load the first row of cursor1
  2. Load the first row of cursor
  3. Check to see if the values in field match
  4. Check to see if the values in maxfield and field1 match
  5. If they match, insert a row, and advance cursor1 to the second row
  6. Load the second row of cursor to do the same checks
  7. Oops! We're not on the first row of cursor1 anymore!
  8. Every time we have we match, another row of cursor1 gets skipped
  9. Eventually, we finish all the rows of cursor
  10. So the for loop advances to the next row if cursor1, which isn't the second row since it's been advanced by every match.
  11. So now with what I assume is the 19th row of cursor1:
  12. We want to loop the values of cursor with the for-loop
  13. But the cursor has already been run to the end in the first loop
  14. The for-loop has nothing left to loop over so it skips the checks.

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

for row1 in cursor1:    
    for row in cursor:      
        if row1.getValue(field) == row.getValue(field):
            if row1.getValue(maxfield) == row.getValue(field1):
                cursor2.insertRow(row)
    cursor.reset()

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

for row1 in cursor1:    
    for row in cursor:      
        if row1.getValue(field) == row.getValue(field):
            if row1.getValue(maxfield) == row.getValue(field1):
                cursor2.insertRow(row)
    cursor.reset()

As it is written with the next() and no reset, it's going to do something like:

  1. Load the first row of cursor1
  2. Load the first row of cursor
  3. Check to see if the values in field match
  4. Check to see if the values in maxfield and field1 match
  5. If they match, insert a row, and advance cursor1 to the second row
  6. Load the second row of cursor to do the same checks
  7. Oops! We're not on the first row of cursor1 anymore!
  8. Every time we have we match, another row of cursor1 gets skipped
  9. Eventually, we finish all the rows of cursor
  10. So the for loop advances to the next row if cursor1, which isn't the second row since it's been advanced by every match.
  11. So now with what I assume is the 19th row of cursor1:
  12. We want to loop the values of cursor with the for-loop
  13. But the cursor has already been run to the end in the first loop
  14. The for-loop has nothing left to loop over so it skips the checks.
added 260 characters in body
Source Link
Marc Pfister
  • 4.1k
  • 17
  • 11

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

for row1 in cursor1:    
    for row in cursor:      
        if row1.getValue(field) == row.getValue(field):
            if row1.getValue(maxfield) == row.getValue(field1):
                cursor2.insertRow(row)
    cursor.reset()

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

for row1 in cursor1:    
    for row in cursor:      
        if row1.getValue(field) == row.getValue(field):
            if row1.getValue(maxfield) == row.getValue(field1):
                cursor2.insertRow(row)
    cursor.reset()
update based on additional information
Source Link
Marc Pfister
  • 4.1k
  • 17
  • 11

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Unless you need to skip a row, row1 = cursor1.next() isn't needed when you're already in a loop like for row1 in cursor1:. The loop will automatically go to the next record for you.

Next problem is that your cursor cursor will complete its iteration after the first run of the cursor1 loop, so it needs to be reset so it starts over from the beginning. So replace row1 = cursor1.next() with cursor.reset().

Source Link
Marc Pfister
  • 4.1k
  • 17
  • 11
Loading