<?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: Setting a Single Record to Selected with Python in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32037#M1119</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: csny490&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The tool MakeFeatureLayer or it's tabular equivalent MakeTableView is a much faster way to "select" features and/or records (use the SQL parameter to select on OID or some other attribute). I'm guessing it's faster than SelectLayerByAttribute since it doesn't have all the fancy selection criteria like "switch selection" and also lacks some of the gp.describe functionality like the .fidset property. MakeFeatureLayer is just stuck in "New Selection" mode. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;featureLayer = "mickey_mouse"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc = r"C:\temp\test.gdb\test"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.MakeFeatureLayer_management(fc, featureLayer, "OBJECTID = 1")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Jul 2010 15:32:20 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2010-07-19T15:32:20Z</dc:date>
    <item>
      <title>Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32035#M1117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: BrendanM&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With Avenue it was possible to select a single record in a table using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;theVTab.GetSelection.Set(rec)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I cannot find an equivalent in Python. The only work-around I can find is using a "Select by Attribute" on the OID field. But this is cumbersome when working with datasets of tens or hundreds of thousands of records.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be much appreciated. Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brendan Magill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jul 2010 20:50:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32035#M1117</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-07-16T20:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32036#M1118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your approach is correct...don't blame Python, blame what has been exposed for Python access, otherwise dive into arcobjects&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jul 2010 22:54:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32036#M1118</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-07-16T22:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32037#M1119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: csny490&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The tool MakeFeatureLayer or it's tabular equivalent MakeTableView is a much faster way to "select" features and/or records (use the SQL parameter to select on OID or some other attribute). I'm guessing it's faster than SelectLayerByAttribute since it doesn't have all the fancy selection criteria like "switch selection" and also lacks some of the gp.describe functionality like the .fidset property. MakeFeatureLayer is just stuck in "New Selection" mode. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;featureLayer = "mickey_mouse"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc = r"C:\temp\test.gdb\test"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.MakeFeatureLayer_management(fc, featureLayer, "OBJECTID = 1")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 15:32:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32037#M1119</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-07-19T15:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32038#M1120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: BrendanM&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Dan &amp;amp; Chris.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am currently trying to run two cursors concurrently - one (SearchCursor) stepping through the records and pulling the relevant values with another (UpdateCursor) selecting records based on the values in the SearchCursor, but this does not seem to be working. Probably cant run two cursors simultaneously.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems I may need to take the plunge into ArcObjects.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 18:35:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32038#M1120</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-07-19T18:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32039#M1121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Haven't tried it, but can you not clone the original file (copy to a dup on disk) then run the search cursor on it and update on the other?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 19:10:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32039#M1121</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-07-19T19:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32040#M1122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: csny490&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;imbeded cursors work fine, but they cam be extreemly slow. If you are basically treating the search cursor like a look up table, you might want to look at using a Python dictionary object rather than an imbeded cursor - it will be WAY faster. A simple example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lookupDict = {}
searchRows = gp.searchcursor(lookupTbl)
searchRow = searchRows.next()
while searchRow:
&amp;nbsp;&amp;nbsp; lookupDict[searchRow.LOOKUPITEM] = [searchRow.FIELDVALUE1,searchRow.FIELDVALUE2]
&amp;nbsp;&amp;nbsp; searchRow = searchRows.next()
del searchRow
del searchRows

updateRows = gp.updatecursor(tableToUpdateTbl)
updateRow = updateRows.next()
while updateRow:
&amp;nbsp;&amp;nbsp; updateRow.MEAN = (lookupDict[updateRow.LOOKUPITEM][0] + lookupDict[updateRow.LOOKUPITEM][1]) / 2
&amp;nbsp;&amp;nbsp; updateRows.UpdateRow(updateRow)
&amp;nbsp;&amp;nbsp; updateRow = updateRows.next()
del updateRow
del updateRows
del lookupDict&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32040#M1122</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-10T21:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32041#M1123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: BrendanM&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry, actually it does work - running two cursors concurrently, that is. It worked well, but, as Chris noted, very slow - took 10 hours to process 50 000 records.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your responses. I will try the dictionary object methodology as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brendan Magill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 07:09:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32041#M1123</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-07-20T07:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32042#M1124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I meant that indeed imbeded cursors work, but there is a big difference between working and working fast. Dictionaries are basically a way to build light-speed database tables(s) in memory. Some practical examples using Python dictionaries:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.esri.com/thread.asp?t=275202&amp;amp;f=1729&amp;amp;c=93#948148"&gt;http://forums.esri.com/thread.asp?t=275202&amp;amp;f=1729&amp;amp;c=93#948148&lt;/A&gt;&lt;SPAN&gt; (see the .zip file)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://arcscripts.esri.com/details.asp?dbid=16700"&gt;http://arcscripts.esri.com/details.asp?dbid=16700&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 15:02:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32042#M1124</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-07-20T15:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a Single Record to Selected with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32043#M1125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: BrendanM&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello Chris&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Apologies. When I said "sorry, actually it does work" I was referring to my previous post where I said running two cursors concurrently doesn't work. Wasn't referring to your comment about imbedded cursors. Thanks for the tips on dictionaries - it is definitely something I need to explore further.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Brendan Magill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 18:20:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/setting-a-single-record-to-selected-with-python/m-p/32043#M1125</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-07-20T18:20:15Z</dc:date>
    </item>
  </channel>
</rss>

