samedi 27 décembre 2014

Loop does not move on to the next row?


I want two make some operation, and I need to determinate the start and end point! I have two tables and I want to do this :



  1. get value (RefName) of the first row from the table 1(Join_Output_12)

  2. get the value of POINT_X & POINT_Y as the start points

  3. Search for the value in table 2 in field (src_RefName),

  4. when the RefName and the src_RefName are the same, select the nbr_RefName

  5. look when the nbr_RefName is the same as copy_field, and return POINT_X & POINT_Y

  6. then do the same for the next row


Table 2Table 1


For doing this I used three loop for, and I think it's turning right, but it does it just for the first row, and doesn't move to the newt row!


The code is this:



>>> cur = arcpy.UpdateCursor("Join_Output_12")
>>> cur2 = arcpy.UpdateCursor("Join_Output_12")
>>> cur_t = arcpy.UpdateCursor("tb20_12_2014_")
>>> del row2, Refname__table_neighbor, start_x1, start_y1, end_x1, end_y1, copy_field
>>> for row in cur :
... Refname_feature = row.getValue("RefName")
... for row_t in cur_t :
... Refname__table_target = row_t.getValue("src_RefName")
... if(Refname__table_target==Refname_feature):
... start_x1 = row.getValue("POINT_X")
... start_y1 = row.getValue("POINT_Y")
... print Refname_feature
... print start_x1
... print start_y1
... Refname__table_neighbor = row_t.getValue("nbr_RefName")
... print Refname__table_neighbor
... for row2 in cur2 :
... copy_field = row2.getValue("copy_field")
... if (copy_field==Refname__table_neighbor):
... end_x1 = row2.getValue("POINT_X")
... end_y1 = row2.getValue("POINT_Y")
... print copy_field
... print end_x1
... print end_y1
... row = cur.next()


The result is:



1
221408.8543
200288.7235
1
1
221408.8543
200288.7235


So I think that the problem comes from for loop!





Aucun commentaire:

Enregistrer un commentaire