<?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: SearchCursor Select Attributes Delete Rows in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398784#M70109</link>
    <description>&lt;P&gt;Yes, that is correct. You need to use update cursor to edit records whereas a search cursor is only used for read-only.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2024 23:13:00 GMT</pubDate>
    <dc:creator>Tom_Laue</dc:creator>
    <dc:date>2024-03-20T23:13:00Z</dc:date>
    <item>
      <title>SearchCursor Select Attributes Delete Rows</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398767#M70104</link>
      <description>&lt;P&gt;I am trying to figure out how to write a Python script that will use Search Cursor to go thru a Feature Class based on a list of attributes in the script and delete the entire row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am not the best code writer, so please bare with me. This is what I have but nothing is working:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;expression = ('45074.0115', '45074.0116', '45074.0117', '45074.0118', '45074.0119', '45074.0120')

with arcpy.da.UpdateCursor(MEWCo_PARCELS_UPDATE, "PID", expression) as cursor:
    for row in cursor:
        row[0] = 0
        cursor.deleteRow()‍‍‍)&lt;/LI-CODE&gt;&lt;P&gt;I know 100% the code is written incorrectly, just not sure what part.&lt;/P&gt;&lt;P&gt;MEWCo_PARCELS_UPDATE is the FC&lt;/P&gt;&lt;P&gt;PID is the field&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 21:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398767#M70104</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2024-03-20T21:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor Select Attributes Delete Rows</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398782#M70108</link>
      <description>&lt;P&gt;Not to get hung up on semantics, but the title and description say "Search Cursor" but the code says "UpdateCursor".&amp;nbsp; I assume the code is correct?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 23:06:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398782#M70108</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2024-03-20T23:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor Select Attributes Delete Rows</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398784#M70109</link>
      <description>&lt;P&gt;Yes, that is correct. You need to use update cursor to edit records whereas a search cursor is only used for read-only.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 23:13:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398784#M70109</guid>
      <dc:creator>Tom_Laue</dc:creator>
      <dc:date>2024-03-20T23:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor Select Attributes Delete Rows</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398788#M70110</link>
      <description>&lt;P&gt;Your expession is not valid. You need to make it a string variable, include a field name, and use some kind of statement or operator with that set of values. Something like:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;expression = "MyField in('45074.0115', '45074.0116', '45074.0117', '45074.0118', '45074.0119', '45074.0120')"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Also, you have numbers formatted as text. Is that correct? And I don't understand the purpose of the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;row[0] = 0&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 23:51:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398788#M70110</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2024-03-20T23:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor Select Attributes Delete Rows</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398865#M70111</link>
      <description>&lt;P&gt;This will get you there. Remove the row[0] = 0 and just make sure you test on a copy of your data before you perform the delete! You are new to coding/arcpy so you need to make sure the code is working exactly as expected. Depending on your working environment you might not be able to retrieve deleted features.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 07:45:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-select-attributes-delete-rows/m-p/1398865#M70111</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-03-21T07:45:40Z</dc:date>
    </item>
  </channel>
</rss>

