<?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: Loop through a list of fcs, select by attributes, and copy to new feature classes results in random shapefile? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024749#M59880</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/107488"&gt;@KathleenHoenke&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Try changing&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# from this 
ditched_features_path = os.path.join(out_name, channelized_gdb)

# to this
ditched_features_path = os.path.join(channelized_gdb, out_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2021 03:30:16 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-02-09T03:30:16Z</dc:date>
    <item>
      <title>Loop through a list of fcs, select by attributes, and copy to new feature classes results in random shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024743#M59876</link>
      <description>&lt;P&gt;I'm trying to loop through a list of feature classes in a geodatabase, extract the polygons whose ATTRIBUTE field values end with x or d, and then copy features into a new feature classes into a new geodatabase. It works to select the correct attributes in one of the fcs, but then it exports it out as a shapefile titled Ditched_Excavated (the name of my output gdb), and keeps overwriting this for each input fc. I'm stumped... TIA!&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Define new clipped NWI
NWI_clip_fgdb = r'F:\Data\NWI\NWI_Wetlands_State_Clip.gdb'
arcpy.env.workspace = NWI_clip_fgdb
clipped_NWI_fcs = arcpy.ListFeatureClasses()
print (clipped_NWI_fcs)

#Define output gdb
channelized_gdb = r'F:\Data\NWI\Ditched_Excavated.gdb'        

# loop throughe each input fc, extract ditched and excavated polygons, write to new fc.
for clipped_NWI_fc in clipped_NWI_fcs:
     arcpy.MakeFeatureLayer_management(clipped_NWI_fc, "lyr")
     whereclause = "ATTRIBUTE LIKE '%r' Or ATTRIBUTE LIKE '%x'"
     selection_type = "NEW_SELECTION"
     arcpy.SelectLayerByAttribute_management("Lyr", selection_type, whereclause)
     in_nwi_path = os.path.join(NWI_clip_fgdb, clipped_NWI_fc)
     out_name = clipped_NWI_fc + "Channelized"
     ditched_features_path = os.path.join(out_name , channelized_gdb)
     arcpy.CopyFeatures_management("Lyr", ditched_features_path)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Feb 2021 03:13:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024743#M59876</guid>
      <dc:creator>KathleenHoenke</dc:creator>
      <dc:date>2021-02-09T03:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through a list of fcs, select by attributes, and copy to new feature classes results in random shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024748#M59879</link>
      <description>&lt;P&gt;Hi Kathleen,&lt;/P&gt;&lt;P&gt;It looks like your 'lyr' was changed to 'Lyr' in your code and your&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ditched_features_path = os.path.join(out_name , channelized_gdb)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is backwards, putting your gdb last.&lt;/P&gt;&lt;P&gt;I think you will need to get the name of the fc, using the describe:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fc_desc = arcpy.Describe(clipped_NWI_fc)
out_name = fc_desc.baseName + 'Channelized'
ditched_features_path = os.path.join(channelized_gdb, out_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 03:44:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024748#M59879</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-02-09T03:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through a list of fcs, select by attributes, and copy to new feature classes results in random shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024749#M59880</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/107488"&gt;@KathleenHoenke&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Try changing&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# from this 
ditched_features_path = os.path.join(out_name, channelized_gdb)

# to this
ditched_features_path = os.path.join(channelized_gdb, out_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 03:30:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024749#M59880</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-02-09T03:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through a list of fcs, select by attributes, and copy to new feature classes results in random shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024755#M59881</link>
      <description>&lt;P&gt;Thank you! I didn't end up needing the describe, but the other changes fixed it, thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 03:55:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024755#M59881</guid>
      <dc:creator>KathleenHoenke</dc:creator>
      <dc:date>2021-02-09T03:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through a list of fcs, select by attributes, and copy to new feature classes results in random shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024756#M59882</link>
      <description>&lt;P&gt;This worked, thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 03:56:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-through-a-list-of-fcs-select-by-attributes/m-p/1024756#M59882</guid>
      <dc:creator>KathleenHoenke</dc:creator>
      <dc:date>2021-02-09T03:56:02Z</dc:date>
    </item>
  </channel>
</rss>

