<?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: How to determine number of records using arcpy.da.SearchCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316400#M24600</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for the suggestions, but I'm looking to avoid a counter.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.GetCount_management doesn't work for you?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Mar 2014 19:22:51 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2014-03-21T19:22:51Z</dc:date>
    <item>
      <title>How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316397#M24597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does anyone know of a quick way to return the number of records in a query constrained Search Cursor using the da module?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;rows = arcpy.da.SearchCursor(someFC,someFields,someQuery)&amp;nbsp; print (len(rows))&amp;nbsp; #I'm sure this used to work with the old cursors, but doesn't work with da.SearchCursor&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 17:46:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316397#M24597</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2014-03-21T17:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316398#M24598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This works (and should honor any selections):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

myFeatClass = r'C:\MyGDB\myFeatureClass'
result = int(arcpy.GetCount_management(fc).getOutput(0))

print result
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This also works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

rowcount = 0
myFeatClass = r'C:\MyGDB\myFeatureClass'
with arcpy.da.SearchCursor(myFeatClass, "*") as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + 1

print rowcount

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit:&amp;nbsp; You can also apply an sql conditional statement too&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

rowcount = 0
sql = "OBJECTID = 29821"
myFeatClass = r'C:\MyGDB\myFeatureClass'
with arcpy.da.SearchCursor(myFeatClass, "*", sql) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + 1

print rowcount

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:02:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316398#M24598</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T15:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316399#M24599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the suggestions, but I'm looking to avoid a counter.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 19:20:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316399#M24599</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2014-03-21T19:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316400#M24600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for the suggestions, but I'm looking to avoid a counter.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.GetCount_management doesn't work for you?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 19:22:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316400#M24600</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-03-21T19:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316401#M24601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You were actually very close in your original entry.&amp;nbsp; Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;rows = [row for row in arcpy.da.SearchCursor(someFC,someFields,someQuery)]&amp;nbsp; print len(rows)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The cursor creates an iterator, which you can't find the length of.&amp;nbsp; The key is to use list comprehension for a nice one liner with the cursor to make your list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, you can always just this as an alternative:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;int(arcpy.GetCount_management(someFC).getOutput(0))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 21:34:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316401#M24601</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2014-03-21T21:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316402#M24602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please, please, &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;please &lt;/SPAN&gt;&lt;SPAN&gt;use James' GetCount solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;result = int(arcpy.GetCount_management(fc).getOutput(0))
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It will be the fastest.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:02:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316402#M24602</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T15:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316403#M24603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Indeed, use arcpy.GetCount_management. In order to limit the number of record by a where clause, create a feature layer (or table view) first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc = r'c:\path\to\fc'
w = '"OBJECTID" &amp;lt; 10'
lr = arcpy.MakeFeatureLayer_management(fc, 'tmp_layer', w).getOutput(0)
result = int(arcpy.GetCount_management(lr).getOutput(0))
arcpy.Delete_management(lr) # deletes the layer, not the feature class data
# result is 9
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:02:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316403#M24603</guid>
      <dc:creator>FilipKrál</dc:creator>
      <dc:date>2021-12-11T15:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316404#M24604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I actually just built one like this today.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lst = [row.getvalue() for row in arcpy.SearchCursor(dataset,expression...enter other parameters you want to include)]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print len(lst)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 02:08:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316404#M24604</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2014-03-25T02:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316405#M24605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would err on the side of the SearchCursor rather than GetCount in case if a request may arise when he may need to include queries on the dataset.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 02:12:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316405#M24605</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2014-03-25T02:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316406#M24606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The number of records determines what method (GetCount or da.SearchCursor) is faster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the number of records is quite large, GetCount is faster, otherwise the searchcursor one liner is faster. I use the latter method (cursor) in some code that recursively (and quickly) needs to determine selected set counts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jason - Curious why you indicate the cursor method is a poor choice (locks?, memory?, ???).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, time
fc = r"C:\csny490\overlay_20130620\ldo_20130620\ldo_database.gdb\crew_code"
time1 = time.clock()
result = int(arcpy.GetCount_management(fc).getOutput(0))
time2 = time.clock()
print "GetCount (" + str(result) + "), took " + str(time2-time1) + " seconds..."
time1 = time.clock()
result = len([r[0] for r in arcpy.da.SearchCursor(fc, ["OID@"])])
time2 = time.clock()
print "SearchCursor (" + str(result) + "), took " + str(time2-time1) + " seconds..." &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Some results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;Table with 8 records:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GetCount (8), took 0.755854384327 seconds...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SearchCursor (8), took 0.136624540949 seconds...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;Table with 81k records:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GetCount (81327), took 0.996590826688 seconds...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SearchCursor (81327), took 0.648470391747 seconds...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;Table with 2 mm records:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GetCount (2133404), took 4.37459715564 seconds...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SearchCursor (2133404), took 11.5886194669 seconds...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:02:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316406#M24606</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T15:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316407#M24607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@Chris -- because of that last, millions-of-records result. There's a certain amount of time required to set up/tear down a GP tool (which is what's causing the first two results in your benchmarks to look the way they do), but a &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;for &lt;/SPAN&gt;&lt;SPAN&gt;loop in a core GP tool looping over rows in its native ArcObjects/C++ implementation will be orders of magnitude faster than that of a &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; loop in Python, not to mention GetCount can do other tricks that the Python code isn't doing like seeing if there is a selection set on the table or layer, and if so just asking for the length of the list of selected records without needing to open a cursor on the actual data.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 19:18:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316407#M24607</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2014-03-25T19:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316408#M24608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason - thanks for the explanation. For the smaller record counts, I too noticed the slight overhead (set up/tear down a GP tool) of the GetCount tool, which is why I started using the cursor method (which didn't seem to have the extra overhead that GetCount does). In my case, I had some code that needed to inspect a recursive feature count hundreds/thousands of times in a loop, and I found the cursor method (&lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;because the record count was relatively small&lt;/SPAN&gt;&lt;SPAN&gt;) was the best performer (BTW: using the .fidSet describe property was the worse).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Per the count of the selected set, you can of course do it like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.MakeFeatureLayer_management(fc, "fl1")
arcpy.SelectLayerByAttribute_management("fl1", "NEW_SELECTION", "LAND_COVER_CD in (41,42)")
result = len([r[0] for r in arcpy.da.SearchCursor("fl1", ["OID@"])])
#Or this if you don't need an actual "selected set"...
result = len([r[0] for r in arcpy.da.SearchCursor(fc, ["OID@"], "LAND_COVER_CD in (41,42)")])&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316408#M24608</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T15:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316409#M24609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for all of the helpful posts.&amp;nbsp; This script works with Workflow Manager, and I think that with my current workflow(below), if I used GetCount, I would have to make 2 feature layers.&amp;nbsp; So I'll go with len([r for r in arcpy.da.SearchCursor....])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Workflow&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Use .sde connection file to connect to default version of database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Get what should be a unique polygon attribute (but isn't always unique)&amp;nbsp; from WMX for a SQL query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Make feature layer of whole feature class without SQL query (The whole feature class is created because the polygon may or may not yet exist in default - rec and posts are scheduled nightly)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Change version (based on WMX user) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Create SearchCursor on version, using SQL query to limit records, and get len(SearchCursor) (Here I could create another feature layer using the SQL query, in order to be able to use GetCount.&amp;nbsp; Seems inefficient?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Based on number of records in search cursor(&amp;gt;1, 1, or 0), do stuff.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2014 11:55:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316409#M24609</guid>
      <dc:creator>BruceBacia</dc:creator>
      <dc:date>2014-04-03T11:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316410#M24610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd suggest you to encapsulate it into a function. I developed a tiny function called SearchCounter derivated from a Validator in a previous blog post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def SearchCounter(cursor):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counts = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for counter in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counts += 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.reset()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return counts

#Previous Code
#...
RecordCount = SearchCounter(&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;arcpy.da.SearchCursor(Table,Fields,Query)&lt;/SPAN&gt;)
#...
#End Code&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:02:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/316410#M24610</guid>
      <dc:creator>Leandro-Zamudio</dc:creator>
      <dc:date>2021-12-11T15:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine number of records using arcpy.da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/1580377#M73676</link>
      <description>&lt;P&gt;This also now works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(table, fields, query) as cursor:
    rows = list(cursor)
    row_count = len(rows)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...though you would then need to re-create the cursor if you want to iterate over the rows for something else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 16:25:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-determine-number-of-records-using-arcpy-da/m-p/1580377#M73676</guid>
      <dc:creator>nlibassi-col</dc:creator>
      <dc:date>2025-01-30T16:25:06Z</dc:date>
    </item>
  </channel>
</rss>

