<?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: Select Row from Feature Class and Copy Features Not Working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/1149433#M63902</link>
    <description>&lt;P&gt;Hi I’m trying to do the same thing any chance I can see your entire python script. I want to select layer by attribute with two conditions example like this x = 1 AND b = 2 and export each row that meets this criteria to a new shapefile. I also want to add the feature classes attributes from the row at end of the output name.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2022 04:46:59 GMT</pubDate>
    <dc:creator>jjeremy525</dc:creator>
    <dc:date>2022-03-02T04:46:59Z</dc:date>
    <item>
      <title>Select Row from Feature Class and Copy Features Not Working</title>
      <link>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/4217#M387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to use arcpy to recreate clicking on a row in an attribute table, and exporting that row to a new class. I'm iterating through a feature class with 12,000+ records and&amp;nbsp;filtering out features that&amp;nbsp;meet a certain criteria (room classification). Using &lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-layer-by-attribute.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-layer-by-attribute.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Select Layer By Attribute&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Copy Features&lt;/A&gt;&amp;nbsp;I'm getting every single row copied over. I think my&amp;nbsp;where clause might be the issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my snippet:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'*'&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;sql_clause&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"WHERE CurrentSpaceClass = 'CR_Reg'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; OID_field &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;OIDFieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp; site &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;8&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; room_number &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;9&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pa_ratio &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;18&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; angle &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;16&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; site_no_space &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; site&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'_'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; room_feature &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; scratch_gdb &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; site_no_space&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;lower&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"_room_"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; room_number
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; where &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'{0} = {1}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddFieldDelimiters&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;OID_field&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;where&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;room_feature&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:10:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/4217#M387</guid>
      <dc:creator>deleted-user-1_r2dgYuILKY</dc:creator>
      <dc:date>2021-12-10T20:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select Row from Feature Class and Copy Features Not Working</title>
      <link>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/4218#M388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you print where (or AddMessage), is it what you're expecting?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best guess:&lt;/P&gt;&lt;PRE class="language-none line-numbers" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE&gt;where = "{0} = '{1}'".format(arcpy.AddFieldDelimiters(fc,OID_field),row[0])&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You should consider adding a check to see if anything is selected, otherwise, yes, you'll return the entire original feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jan 2019 21:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/4218#M388</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2019-01-07T21:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select Row from Feature Class and Copy Features Not Working</title>
      <link>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/4219#M389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah duh, I just realized I needed to assign&amp;nbsp;arcpy.SelectLayerByAttribute to a variable "selection" and then copy that. That did the trick!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jan 2019 22:12:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/4219#M389</guid>
      <dc:creator>deleted-user-1_r2dgYuILKY</dc:creator>
      <dc:date>2019-01-07T22:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select Row from Feature Class and Copy Features Not Working</title>
      <link>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/1149433#M63902</link>
      <description>&lt;P&gt;Hi I’m trying to do the same thing any chance I can see your entire python script. I want to select layer by attribute with two conditions example like this x = 1 AND b = 2 and export each row that meets this criteria to a new shapefile. I also want to add the feature classes attributes from the row at end of the output name.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 04:46:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-row-from-feature-class-and-copy-features/m-p/1149433#M63902</guid>
      <dc:creator>jjeremy525</dc:creator>
      <dc:date>2022-03-02T04:46:59Z</dc:date>
    </item>
  </channel>
</rss>

