<?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: Insert cursor multiple rows in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/insert-cursor-multiple-rows/m-p/583058#M45697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How are you doing this? Not knowing makes it hard to locate the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The insert cursor itself should run pretty quickly, but if you are fetching the input for each row from all the various sources as each row is needed, I can see that being very slow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Your reference to the source of the row items leads me to think you are doing something like that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gathering all the row data first, before inserting it into the feature class, would help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try building a list of the geometry object and attributes for each row, and nest the row lists in an enclosing list. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then use that list to feed the cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps a dictionary of rows keyed on a unique ID may be appropriate instead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In any event, the idea is to feed the cursor as fast as it can spit the rows into the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, you might be doing something like this already.... hard to tell.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Working on an in-memory feature class would likely help too.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Feb 2012 18:29:50 GMT</pubDate>
    <dc:creator>markdenil</dc:creator>
    <dc:date>2012-02-07T18:29:50Z</dc:date>
    <item>
      <title>Insert cursor multiple rows</title>
      <link>https://community.esri.com/t5/python-questions/insert-cursor-multiple-rows/m-p/583056#M45695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using an insert cursor to create many (&amp;gt;5,000) new rows in a feature class.&amp;nbsp; The cursor is drawing shapes from one feature class and a variety of attributes from a series to tables to create a large "flatfile" featureclass.&amp;nbsp; It is taking a very long time to run.&amp;nbsp; In VBA, there was a "rowbuffer" object that was more efficient than inserting single row objects -- is there something similar in Python?&amp;nbsp; Is there a faster way to add rows than an insert cursor on the feature class object (by creating a feature layer or table view first)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 15:04:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-cursor-multiple-rows/m-p/583056#M45695</guid>
      <dc:creator>DonKatnik</dc:creator>
      <dc:date>2012-02-07T15:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Insert cursor multiple rows</title>
      <link>https://community.esri.com/t5/python-questions/insert-cursor-multiple-rows/m-p/583057#M45696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am using an insert cursor to create many (&amp;gt;5,000) new rows in a feature class.&amp;nbsp;&amp;nbsp;&amp;nbsp; It is taking a very long time to run.&amp;nbsp; In VBA, there was a "rowbuffer" object that was more efficient than inserting single row objects -- is there something similar in Python?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may want to try buffering using the in_memory workspace: create a feature class in the in_memory workspace, insert rows to it using a cursor, then copy them out to disk, use delete rows tool to clear it, repeat. At the end of your process append your pieces together. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could still use your VBA method if you used a .NET addin instead of Python (none of that for me, thanks).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Esri is addressing this shortcoming of arcpy (slow cursors) with the new arcpy.da method in Arc 10.1. I haven't tried it yet but have been told it will be dramatically faster.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 18:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-cursor-multiple-rows/m-p/583057#M45696</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-02-07T18:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Insert cursor multiple rows</title>
      <link>https://community.esri.com/t5/python-questions/insert-cursor-multiple-rows/m-p/583058#M45697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How are you doing this? Not knowing makes it hard to locate the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The insert cursor itself should run pretty quickly, but if you are fetching the input for each row from all the various sources as each row is needed, I can see that being very slow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Your reference to the source of the row items leads me to think you are doing something like that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gathering all the row data first, before inserting it into the feature class, would help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try building a list of the geometry object and attributes for each row, and nest the row lists in an enclosing list. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then use that list to feed the cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps a dictionary of rows keyed on a unique ID may be appropriate instead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In any event, the idea is to feed the cursor as fast as it can spit the rows into the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, you might be doing something like this already.... hard to tell.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Working on an in-memory feature class would likely help too.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2012 18:29:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-cursor-multiple-rows/m-p/583058#M45697</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-02-07T18:29:50Z</dc:date>
    </item>
  </channel>
</rss>

