AnsweredAssumed Answered

Arcpy for loop gives n-1 results

Question asked by n.ueberschaeresri-rw-esridist Employee on Feb 10, 2017
Latest reply on Feb 15, 2017 by n.ueberschaeresri-rw-esridist

I have a problem with my for loop. 

In an array profile_nrs all the numbers are stored I want to create points for in an existing feature class. When I print these values I get the expected nr of values (and also the correct values). Now I am creating points with an insertCursor and print in the end which point nr was added. I get all the (in this case) 18 points printed. But when I look into my file I receive only 17 points. Any advise is highly appreciated. I don't see any potential cause for this "misbehavior". My feeling tells me that it must not be looping through the numbers itself but through the index but then I wouldn't get nr 18 printed, would I?

 

Here the main part of the module: 

 

for profile in profile_nrs:
    newPoint=arcpy.da.InsertCursor(points, fillnames)
    newPoint.insertRow(fillValues)
    print("point "+str(profile) +" added to All_points")

 

Inside the for loop I have a couple of other loops to get the fillnames and fillvalues but I don't see anywhere how this could influence the output. Especially if it says it added nr 18 but obviously it didn't...

 

Thanks in advance for helping me with this. 

Outcomes