<?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: Fast way to delete row from table in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147817#M11474</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I would implement Marcin's change. Your original script is running through every feature you want to delete for every row in your dataset. Uneconomical to say the least.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Mar 2012 12:28:11 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2012-03-07T12:28:11Z</dc:date>
    <item>
      <title>Fast way to delete row from table</title>
      <link>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147815#M11472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi, all &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to delete row from file geodatabase table using following code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
import math

arcpy.env.workspace = r'C:\TempArcGISCalculate\Scratch.gdb'
arcpy.env.overwriteOutput = True

intable="Section0011"

Statstbl="C:/TempArcGISCalculate/Scratch.gdb/S11FirstStats"
Query = '"FREQUENCY"=1'

records = arcpy.SearchCursor(Statstbl,Query)
singlelst = []
for record in records:
&amp;nbsp;&amp;nbsp;&amp;nbsp; singlelst.append(record.getValue('Trace')) # it adds data who has single point only

del records
del record


pts = arcpy.UpdateCursor(intable)

for pt in pts:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in singlelst:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pt.Trace == int(i):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Deleting:", pt.OBJECTID, pt.Trace
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.deleteRow(pt)

del pts, pt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the table "Section0011", I have 534975 rows. When the script runs, it only remove about 1000 rows in couple hours, but has not finished yet. Is there any fast way to run deleteRow? please help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks lot&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2012 22:49:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147815#M11472</guid>
      <dc:creator>zhengniu1</dc:creator>
      <dc:date>2012-03-06T22:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to delete row from table</title>
      <link>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147816#M11473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In last part of the script try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for pt in pts:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pt.Trace in singlelst:&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;instead of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for pt in pts:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in singlelst:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pt.Trace == int(i):&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I simulated similar script situation with this code change and for feature class with over 550 000 rows, ~13 000 rows were deleted in less than 4 minutes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:01:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147816#M11473</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2021-12-11T08:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to delete row from table</title>
      <link>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147817#M11474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I would implement Marcin's change. Your original script is running through every feature you want to delete for every row in your dataset. Uneconomical to say the least.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 12:28:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147817#M11474</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-03-07T12:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Fast way to delete row from table</title>
      <link>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147818#M11475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Marcin and Mathew, Thank you so much&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 14:23:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fast-way-to-delete-row-from-table/m-p/147818#M11475</guid>
      <dc:creator>zhengniu1</dc:creator>
      <dc:date>2012-03-07T14:23:42Z</dc:date>
    </item>
  </channel>
</rss>

