AnsweredAssumed Answered

del cur error ????

Question asked by progis99 on Feb 6, 2015
Latest reply on Feb 7, 2015 by progis99

This is what I wrote from the book Programming ArcGIS 10.1 with Python Cookbook wrote by Eric Pimper and it is on Chapter 7th.




#Script to Import data to a feature class within a geodatabase

import arcpy, os

arcpy.env.workspace = "C:/ArcpyBook/data/Wildfires/WildlandFires.mdb"

f = open("C:/ArcpyBook/data/Wildfires/NorthAmericaWildfires_2007275.txt", "r")




    # the output feature class name

    outputFC = arcpy.GetParameterAsText(0)

    # the template feature class that defines the attribute schema

    fClassTemplate = arcpy.GetParameterAsText(1)

    #Open the file to read

    f = open(arcpy.GetParameterAsText(2), 'r')

    arcpy.CreateFeatureclass_management(os.path.split(outputFC)[0], os.path(outputFC)[1]), "point", (fClassTemplate)

    lstFires = f.readlines()

    cur = arcpy.InsertCursor(outputFC)

    cntr = 1

    for fire in lstFires:

        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



The error showed here


Traceback (most recent call last):

  File "C:\ArcpyBook\Ch7\", line 34, in <module>

    del cur

NameError: name 'cur' is not defined