<?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 Can't get searchcursor, listfields etc to work - get same error message each time in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415679#M1398</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;SPAN&gt;Original User: &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:bhickman1989@gmail.com"&gt;bhickman1989@gmail.com&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Original Date: 2012-01-02T08:05:42-0600&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been struggling with this for a while now, for some reason I'm unable to get listfields and searchcursor to work in Python. Below is a very simple script I'm using to test my system and I get the error message seen below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, os, sys, arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\Users\Ben\Documents\E.ON Work\Practise.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "C:\Users\Ben\Documents\E.ON Work\Practise.mxd"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc = "C:\Users\Ben\Documents\ArcGIS\OS OpenData\scotland_and_wales_region_region.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor("scotland_and_wales_region_region")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Have also tried rows = arcpy.SearchCursor(fc) and get the same error message&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; exec codeObject in __main__.__dict__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Users\Ben\Documents\E.ON Work\Scripts\Row work.py", line 10, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; rows = arcpy.SearchCursor("scotland_and_wales_region_region")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 804, in SearchCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return gp.searchCursor(*args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 357, in searchCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; self._gp.SearchCursor(*gp_fixargs(args)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty new to programming and python in general but everywhere I look I can't see anyone getting the same error. Is there something else I need to import? The two python codes that the error is referring to are attached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would really appreciate some help on this one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ben&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Jan 2012 14:05:42 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-01-02T14:05:42Z</dc:date>
    <item>
      <title>Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415679#M1398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;SPAN&gt;Original User: &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:bhickman1989@gmail.com"&gt;bhickman1989@gmail.com&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Original Date: 2012-01-02T08:05:42-0600&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been struggling with this for a while now, for some reason I'm unable to get listfields and searchcursor to work in Python. Below is a very simple script I'm using to test my system and I get the error message seen below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, os, sys, arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\Users\Ben\Documents\E.ON Work\Practise.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "C:\Users\Ben\Documents\E.ON Work\Practise.mxd"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc = "C:\Users\Ben\Documents\ArcGIS\OS OpenData\scotland_and_wales_region_region.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor("scotland_and_wales_region_region")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Have also tried rows = arcpy.SearchCursor(fc) and get the same error message&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; exec codeObject in __main__.__dict__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Users\Ben\Documents\E.ON Work\Scripts\Row work.py", line 10, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; rows = arcpy.SearchCursor("scotland_and_wales_region_region")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 804, in SearchCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return gp.searchCursor(*args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 357, in searchCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; self._gp.SearchCursor(*gp_fixargs(args)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty new to programming and python in general but everywhere I look I can't see anyone getting the same error. Is there something else I need to import? The two python codes that the error is referring to are attached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would really appreciate some help on this one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ben&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jan 2012 14:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415679#M1398</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-01-02T14:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415680#M1399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In Python either use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;raw notation&amp;nbsp;&amp;nbsp;&amp;nbsp; r"c:\temp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;double backslashes "c:\\temp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;single foreslashes "c:/temp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when specifying path names&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jan 2012 14:50:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415680#M1399</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2012-01-02T14:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415681#M1400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;SPAN&gt;Original User: &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:bhickman1989@gmail.com"&gt;bhickman1989@gmail.com&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for that, but even when I do take up your suggestion the exact same error message is coming up - namely from the searchcursor function&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ben&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jan 2012 15:27:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415681#M1400</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-01-02T15:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415682#M1401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try importing less. Something like this should not have a problem as long as the shapefile actually exists in that location and isn't already open by another application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

fc = r"C:\Users\Ben\Documents\ArcGIS\OS OpenData\scotland_and_wales_region_region.shp"

rows = arcpy.SearchCursor(fc)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:50:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415682#M1401</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T18:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415683#M1402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: bruce.nielsen&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your workspace should be a folder or geodatabase, not an .mxd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 16:48:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415683#M1402</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-01-04T16:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415684#M1403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the replies. I tried that code and got exactly the same error message (?) With the _base script there is the following lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;class Geoprocessor(object):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#a few defined functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; def searchCursor(self, *args):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; """GP function SearchCursor"""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; from ..arcobjects.arcobjectconversion import convertArcObjectToPythonObject&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return convertArcObjectToPythonObject(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; self._gp.SearchCursor(*gp_fixargs(args)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does that look right? Also the _init_ script looks very short (see my earlier attached files)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I really appreciate any help you can give on this!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;With regards to calling the mxd this is what I've been doing for vrious scripts before and they've all worked perfectly...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ben&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 19:39:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415684#M1403</guid>
      <dc:creator>BenHickman</dc:creator>
      <dc:date>2012-01-04T19:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415685#M1404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: jjbuckle&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Was this ever resolved?&amp;nbsp; I'm getting the exact same error message with a script that worked fine 3 weeks ago. I can't execute even the simplest SearchCursor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 22:42:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415685#M1404</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-03-12T22:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get searchcursor, listfields etc to work - get same error message each time</title>
      <link>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415686#M1405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Double check your file pathnames - it probably just can't find the file.&amp;nbsp; For example it doesn't like that extra space in the OP's code.&amp;nbsp; I was going crazy with this error message until I realized I was trying to use the extension for a File geodatabase (.gdb) with my personal geodatabase (.mdb).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jul 2013 05:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/can-t-get-searchcursor-listfields-etc-to-work-get/m-p/415686#M1405</guid>
      <dc:creator>LauraGriffin</dc:creator>
      <dc:date>2013-07-26T05:13:08Z</dc:date>
    </item>
  </channel>
</rss>

