I'm trying to delete a row from a coverage
I'm using arcpy 10.3.1
the code that i am using is (to be able to reproduce the issue)
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">count_row</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
i <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> data<SPAN class="punctuation token">:</SPAN>
i <SPAN class="operator token">+=</SPAN> <SPAN class="number token">1</SPAN>
data<SPAN class="punctuation token">.</SPAN>reset<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN> i
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">'C:/Data/cea01apr'</SPAN>
feature <SPAN class="operator token">=</SPAN> <SPAN class="string token">'point'</SPAN>
fidfilter<SPAN class="operator token">=</SPAN> <SPAN class="string token">'fid = 1'</SPAN>
featureClassList <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
fieldList <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFields<SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">)</SPAN>
fieldString <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> fieldList<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">,</SPAN> fieldString<SPAN class="punctuation token">,</SPAN> fidfilter<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursorupdate<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Number of rows:'</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>count_row<SPAN class="punctuation token">(</SPAN>cursorupdate<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
rowupdate <SPAN class="operator token">=</SPAN> cursorupdate<SPAN class="punctuation token">.</SPAN>next<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>rowupdate<SPAN class="punctuation token">[</SPAN><SPAN class="number token">12</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
rowupdate<SPAN class="punctuation token">[</SPAN><SPAN class="number token">12</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+=</SPAN> <SPAN class="string token">'h'</SPAN>
cursorupdate<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>rowupdate<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">,</SPAN> fieldString<SPAN class="punctuation token">,</SPAN> fidfilter<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursorupdate<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Number of rows:'</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>count_row<SPAN class="punctuation token">(</SPAN>cursorupdate<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
rowupdate <SPAN class="operator token">=</SPAN> cursorupdate<SPAN class="punctuation token">.</SPAN>next<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> rowupdate<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>rowupdate<SPAN class="punctuation token">[</SPAN><SPAN class="number token">12</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">,</SPAN> fieldString<SPAN class="punctuation token">,</SPAN> fidfilter<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursorupdate1<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Number of rows:'</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>count_row<SPAN class="punctuation token">(</SPAN>cursorupdate1<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursorupdate1<SPAN class="punctuation token">:</SPAN>
cursorupdate1<SPAN class="punctuation token">.</SPAN>deleteRow<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
raw_input<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Press the <ENTER> key to exit'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
the output of that script is
C:\Data>test.py
Number of rows:1
hhhhhhhhhhhhhhhh
Number of rows:1
hhhhhhhhhhhhhhhhh
Number of rows:1
Traceback (most recent call last):
File "C:\Data\test.py", line 39, in <module>
cursorupdate1.deleteRow()
SystemError: error return without exception set<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I have tried this
arcpy<SPAN class="punctuation token">.</SPAN>MakeTableView_management<SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'test'</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'test'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'NEW_SELECTION'</SPAN><SPAN class="punctuation token">,</SPAN> fidfilter<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>DeleteRows_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'test'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
and i'm getting this error
Traceback (most recent call last):
File "C:\Data\test.py", line 41, in <module>
arcpy.DeleteRows_management('test')
File "C:\***\cots\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 15352, in DeleteRows
raise e
arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
Failed to execute (DeleteRows).<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>trying the old arcpy.UpdateCursor
cursorupdate2 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#print('Number of rows:' + str(count_row(cursorupdate2)))</SPAN>
row <SPAN class="operator token">=</SPAN> cursorupdate2<SPAN class="punctuation token">.</SPAN>next<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'delete'</SPAN><SPAN class="punctuation token">)</SPAN>
cursorupdate2<SPAN class="punctuation token">.</SPAN>deleteRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>will result into
C:\Data>test.py
ArcInfo
Number of rows:1
hhhhhhhhhhhhhhhhhhhh
Number of rows:1
hhhhhhhhhhhhhhhhhhhhh
delete
Traceback (most recent call last):
File "C:\Data\test.py", line 56, in <module>
cursorupdate2.deleteRow(row)
File "C:\***\cots\ArcGIS\Desktop10.3\ArcPy\arcpy\arcobjects\arcobjects.py", line 110, in deleteRow
return convertArcObjectToPythonObject(self._arc_object.DeleteRow(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Error executing function.<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
uncommenting the line for the number of rows will actually crash python.exe