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")
try:
# 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:
continue
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)
cur.insertRow(feat)
arcpy.AddMessage("Record number" + str(cntr) + "written to feature class")
cntr = cntr + 1
except:
print arcpy.GetMessages()
finally:
del cur
f.close()
The error showed here
Traceback (most recent call last):
File "C:\ArcpyBook\Ch7\InsertWildfires.py", line 34, in <module>
del cur
NameError: name 'cur' is not defined