The below code quits at the "cur = " line. Is it an error with arcpy module, my other scripts have worked with importing arcpy. I cannot determine if it is not recognizing the 'InsertCursor'. Any idea how to get it to succeed? I have checked the links. It fails at "stop 2"

import arcpy, os

    arcpy.env.workspace = "H:/Documents/Exercises/Data/WildfireData/WildlandFires.mdb"

    f = open("H:/Documents/Exercises/Data/WildfireData/NorthAmericaWildfires_2007275.txt", "r")

    lstFires = f.readlines()
    print "stop2"
    cur = arcpy.InsertCursor("FireIncidents")
    print "stop3"
    cntr = 1
    for fire in lstFires:
        print "stop"
        if 'Latitude' in fire:
        vals = fire.split(",")
        latitude = float(vals[0])
        longitude = float(vals[1])
        confid = int(vals[2])
        pnt = arcpy.Point(longitude, latitude)
        feat = cur.newRow()
        feat.shape = pnt
        feat.setValue("CONFIDENCEVALUE", confid)
        arcpy.AddMessage("Record number " + str(cntr) + " written to feature class")
        cntr = cntr + 1
    print arcpy.GetMessages()
##    del cur
##    f.close()

closed as unclear what you're asking by PolyGeo Jul 29 '16 at 6:04

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Please paste the actual error message. – Jason Scheirer Aug 20 '13 at 22:13
  • Since you are using a personal geodatabase, what version of arcpy is this as well? There are a lot of things that can go wrong with editing a personal geodatabase (concurrent writers, lock files, etc.), so both the error message and version are important. – blord-castillo Aug 20 '13 at 22:31
  • It passes over the rest of the code. If I include the 'finally' exception, than it has: 'Traceback (most recent call last): File "H:\Documents\Exercises\scripts\InsertWildfires.py", line 35, in <module> del cur NameError: name 'cur' is not defined' – Carla GB Aug 20 '13 at 22:36
  • The version is ArcGis 10.1 - Python 2.7.2 – Carla GB Aug 20 '13 at 22:40
  • I think the first step when trying to debug something which is not obvious should be to remove the try/except statements because they can mask the error messages that Python provides. Without the precise error message, matched to a code snippet that leads to it, it is difficult it is difficult to be certain about where you are stuck. – PolyGeo Jul 29 '16 at 6:01

It sounds like you are trying to delete cur, which doesn't exist. You would have to check if it doesn't exist before deleting it.

Since you are using ArcMap 10.1, you should use the data access module as it is faster than the "normal" cursor object and supports with statements, which can guarantee the closure of your cursor, thereby removing the need to delete it.

  • The "cur =" line where is it defined, that is the error, therefore it is not seen as existing. This is a example in a tutorial so I expect it to work as in so using a different module would change multiple things in the example. – Carla GB Aug 21 '13 at 14:59
  • @CarlaGB, check to see if cur ever exists. – Paul Aug 21 '13 at 15:33

This is a tricky issue for someone who has little or no experience with ArcGIS and python scripting.

I have done the same course, and had the same issue.

You can see when debugging that the script stops at 'cur = arcpy.InsertCursor("FireIncidents")', and it appears the script has an issue with the personal geodatabase.

If the feature class is exported to a shapefile, and the workspace and cursor are altered to reflect these changes, then the script ought to work.


The same personal geodatabase issue is present in the second part of the course dealing with arcpy.da

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