<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: del cur error ???? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382658#M30142</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. That is what I thought so. Does that mean ESRI took out the cur sytanx ? Ok, I will look into that as what you suggest. I have googled it as well but did not find it. I tried cursor and it came back an error...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Feb 2015 22:35:44 GMT</pubDate>
    <dc:creator>DEAF_PROBERT_68</dc:creator>
    <dc:date>2015-02-06T22:35:44Z</dc:date>
    <item>
      <title>del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382656#M30140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Script to Import data to a feature class within a geodatabase&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "C:/ArcpyBook/data/Wildfires/WildlandFires.mdb"&lt;/P&gt;&lt;P&gt;f = open("C:/ArcpyBook/data/Wildfires/NorthAmericaWildfires_2007275.txt", "r")&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # the output feature class name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputFC = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # the template feature class that defines the attribute schema&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fClassTemplate = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Open the file to read&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(arcpy.GetParameterAsText(2), 'r')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(os.path.split(outputFC)[0], os.path(outputFC)[1]), "point", (fClassTemplate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstFires = f.readlines()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur = arcpy.InsertCursor(outputFC)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cntr = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fire in lstFires:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 'Latitude' in fire:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vals = fire.split(",")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; latitude = float(vals[0])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; longitude = float(vals[1])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; confid = int(vals[2])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = arcpy.Point(longitude, latitude)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = cur.newRow()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.shape = pnt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.setValue("CONFIDENCEVALUE", confid)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.insertRow(feat)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Record number" + str(cntr) + "written to feature class")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cntr = cntr + 1&lt;/P&gt;&lt;P&gt;except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/P&gt;&lt;P&gt;finally:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cur&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error showed here &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\ArcpyBook\Ch7\InsertWildfires.py", line 34, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cur&lt;/P&gt;&lt;P&gt;NameError: name 'cur' is not defined&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 22:24:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382656#M30140</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-06T22:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382657#M30141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect it is already gone... whenever you run a script through an IDE, you can inspect its variables using&lt;/P&gt;&lt;P&gt;locals().keys()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (or globals or vars .keys() )&lt;/P&gt;&lt;P&gt;to see what namespace remains after a script is run and what has been delete is what is in your script and these values&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 22:33:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382657#M30141</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-06T22:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382658#M30142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. That is what I thought so. Does that mean ESRI took out the cur sytanx ? Ok, I will look into that as what you suggest. I have googled it as well but did not find it. I tried cursor and it came back an error...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 22:35:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382658#M30142</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-06T22:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382659#M30143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert, if you could use Syntax highlighting in the advanced editor, it would make reading and discussing your code easier for commenters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are getting that error because of the &lt;SPAN style="font-family: courier new,courier;"&gt;del cur&lt;/SPAN&gt; statement in the &lt;SPAN style="font-family: courier new,courier;"&gt;finally&lt;/SPAN&gt; section of your code.&amp;nbsp; In Python error handling, the &lt;SPAN style="font-family: courier new,courier;"&gt;finally&lt;/SPAN&gt; clause is always executed before exiting the &lt;SPAN style="font-family: courier new,courier;"&gt;try&lt;/SPAN&gt; statement, even if there was an error.&amp;nbsp; In your case, you had an error either while creating the cursor object or before, and the cursor object was never instantiated.&amp;nbsp; Since it wasn't instantiated, it can't be deleted in the finally clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the code, you should have received another error message before the del cur error.&amp;nbsp; What other messages did you receive?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 22:42:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382659#M30143</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-02-06T22:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382660#M30144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an example....&amp;nbsp; before a script is run...a script is run with no namespace deletion...then the namespace that remains after&lt;/P&gt;&lt;P&gt;You can get real fancy and do set differences etc etc if you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = set(locals().keys())
&amp;gt;&amp;gt;&amp;gt; a = list(set(locals().keys()))
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; a = list(set(locals().keys()))
&amp;gt;&amp;gt;&amp;gt; a.sort()
&amp;gt;&amp;gt;&amp;gt; a
['__builtins__', '__doc__', '__name__', '__package__', 'a', 'pywin']
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; # now run a script....
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; 
Running...C:\!Scripts\Cursors\cursor_functions.py
Spatial Reference NAD_1983_CSRS_MTM_9
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; b = list(set(locals().keys()))
&amp;gt;&amp;gt;&amp;gt; b.sort()
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; a
['__builtins__', '__doc__', '__name__', '__package__', 'a', 'pywin']
&amp;gt;&amp;gt;&amp;gt; b
['SR', 'SR_PCSCode', '__builtins__', '__doc__', '__name__', '__package__', 'a', 'arcpy', 'desc', 'find_overlaps', 'input_shp', 'move', 'os', 'poly_pnts', 'pywin', 'sys']
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:37:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382660#M30144</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T17:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382661#M30145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where do I find this information in an IDE ? Would Pyscripter show the avaiable variable to replace the cur ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Feb 2015 04:19:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382661#M30145</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-07T04:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382662#M30146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can run the samples I posted in PyScripter in the interactive section&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Feb 2015 07:18:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382662#M30146</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-07T07:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: del cur error ????</title>
      <link>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382663#M30147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay I finally figured it out !&amp;nbsp; Apparently the book on Chapter 7 has some errors in it as I was trying to work on them in Pyscripter and Python Window and got it worked ! This HAS nothing to do with the del cur I had to re-read the instructions and found that the chapter mention to delete two hardcoded THAT should be include in the python script ! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp;&amp;nbsp; phew !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the correct coding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Script to Import data to a feature class within a geodatabase&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "C:/ArcpyBook/data/Wildfires/WildlandFires.mdb"&lt;/P&gt;&lt;P&gt;f = open("C:/ArcpyBook/data/Wildfires/NorthAmericaWildfires_2007275.txt", "r")&lt;/P&gt;&lt;P&gt;cur = arcpy.InsertCursor("FireIncidents")&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # the output feature class name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputFC = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # the template feature class that defines the attribute schema&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fClassTemplate = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Open the file to read&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(arcpy.GetParameterAsText(2), 'r')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(os.path.split(outputFC)[0],os.path.split(outputFC)[1],"POINT", fClassTemplate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstFires = f.readlines()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur = arcpy.InsertCursor(outputFC)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cntr = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fire in lstFires:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 'Latitude' in fire:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vals = fire.split(",")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; latitude = float(vals[0])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; longitude = float(vals[1])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; confid = int(vals[2])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt = arcpy.Point(longitude, latitude)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = cur.newRow()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.shape = pnt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.setValue("CONFIDENCEVALUE", confid)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.insertRow(feat)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Record number " + str(cntr) + "written to feature class")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cntr = cntr + 1&lt;/P&gt;&lt;P&gt;except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/P&gt;&lt;P&gt;finally:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cur&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Feb 2015 16:04:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/del-cur-error/m-p/382663#M30147</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2015-02-07T16:04:49Z</dc:date>
    </item>
  </channel>
</rss>

