<?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: Fastest way to get number of rows in a da.SearchCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146126#M11418</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks James,&lt;/P&gt;&lt;P&gt;I was trying to avoid making a query table but it seems that's the the quickest approach that doesn't require iterating. However using the MakeQueryTable tool did require spinning up the geoprocessor which took some time so in the end I actually found it was still faster to just iterate and count the rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14140839656261876" jivemacro_uid="_14140839656261876"&gt;
&lt;P&gt;with arcpy.da.SearchCursor(FeatureLayer, "SHAPE@", SuperDuperAwesomeQuery) as rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowCount = 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowCount = rowCount + 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print rowCount&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows&lt;/P&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Oct 2014 16:52:00 GMT</pubDate>
    <dc:creator>JohnDye</dc:creator>
    <dc:date>2014-10-23T16:52:00Z</dc:date>
    <item>
      <title>Fastest way to get number of rows in a da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146123#M11415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anyone know of a quick way to count the number of records returned by a da.SearchCursor with a where_clause applied?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14140780711592597 jive_text_macro" jivemacro_uid="_14140780711592597" modifiedtitle="true"&gt;
&lt;P&gt;with arcpy.da.SearchCursor(MyLayer, "SHAPE@", SuperDuperAwesomeQuery) as rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # how do I figured out how many records are in rows without iterating through rows???&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 15:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146123#M11415</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-10-23T15:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest way to get number of rows in a da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146124#M11416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://gis.stackexchange.com/questions/30140/fastest-way-to-count-the-number-of-features-in-a-feature-class" title="http://gis.stackexchange.com/questions/30140/fastest-way-to-count-the-number-of-features-in-a-feature-class"&gt;arcgis desktop - Fastest way to count the number of features in a feature class? - Geographic Information Systems Stack …&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 15:53:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146124#M11416</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-10-23T15:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest way to get number of rows in a da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146125#M11417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alternative method (I don't know it this is faster):&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14140802959018979 jive_text_macro" jivemacro_uid="_14140802959018979"&gt;
&lt;P&gt;sql = "ObjectId=1"&lt;/P&gt;
&lt;P&gt;_dfsource = r'H:\Documents\ArcGIS\Default.gdb\L8_Parcel'&lt;/P&gt;
&lt;P&gt;_numparr = arcpy.da.FeatureClassToNumPyArray(_dfsource, ["ObjectId"], sql)&lt;/P&gt;
&lt;P&gt;rowcount = len(_numparr)&lt;/P&gt;
&lt;P&gt;print rowcount&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 16:05:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146125#M11417</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-10-23T16:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest way to get number of rows in a da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146126#M11418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks James,&lt;/P&gt;&lt;P&gt;I was trying to avoid making a query table but it seems that's the the quickest approach that doesn't require iterating. However using the MakeQueryTable tool did require spinning up the geoprocessor which took some time so in the end I actually found it was still faster to just iterate and count the rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14140839656261876" jivemacro_uid="_14140839656261876"&gt;
&lt;P&gt;with arcpy.da.SearchCursor(FeatureLayer, "SHAPE@", SuperDuperAwesomeQuery) as rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowCount = 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowCount = rowCount + 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print rowCount&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows&lt;/P&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 16:52:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146126#M11418</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-10-23T16:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest way to get number of rows in a da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146127#M11419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;row count = len(list(i for i in arcpy.da.SearchCursor(fc, fields, query)))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 17:33:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146127#M11419</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2014-10-23T17:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest way to get number of rows in a da.SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146128#M11420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Niiice. So obvious once I saw it. Sorry, I already gave the answer to James.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 17:43:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fastest-way-to-get-number-of-rows-in-a-da/m-p/146128#M11420</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2014-10-23T17:43:22Z</dc:date>
    </item>
  </channel>
</rss>

