I'm writing a program to count the number of times a polyline self-intersects. I create a new feature class to keep track of the line and the number of intersections. The feature class is created with the appropriate fields but it is not populated with the information. So I simplified the code to just look at the search cursor and insert cursor (as shown below) and this simple code does not populate the attribute table. I've used a similar code before to create a feature class and populate the table and it works fine. This seems like it should work, does anybody see anything wrong with this? (This is typed directly into the Python window in the ArcMap document containing the feature class). The fields intCount and Trip_ID are type double.

import arcpy

Fields = ['SHAPE@','intCount','Trip_ID'] 
insCur = arcpy.da.InsertCursor("Bikemap_SelfInt",Fields) 

with arcpy.da.SearchCursor("BikemapTC_linesTEMP",["SHAPE@","trip_id"]) as cursor:
    intCount = 0
    for row in cursor:
        segments = row[0]
        trip_id = row[1]
        intCount +=1
        insCur.insertRow([segments, intCount, trip_id])
del insCur

  • I Think what you show should work. InsertCursors are tricky. Try passing a tuple instead of list: insCur.insertRow((segments, intCount, trip_id))
    – BERA
    Mar 19, 2020 at 10:52
  • 1
    Seems like it should work; almost exact same code in another program I wrote did work. The tuple didn't work, but thanks.
    – Mathwiz
    Mar 19, 2020 at 10:58
  • You haven't flushed the cursor by deleting it del insCur
    – Vince
    Mar 19, 2020 at 11:08
  • Thanks, I actually realized that and added it, still not working.
    – Mathwiz
    Mar 19, 2020 at 11:26

1 Answer 1


I don't know why it didn't work before, but I created a new arcMap document and added a test file, and it worked fine. The code is okay, maybe the arcMap doc was corrupted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.