<?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: Creating a python list of FCs in subdirectories and append to a FC in a FGDB in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-a-python-list-of-fcs-in-subdirectories/m-p/687954#M53284</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are attempting to pass an actual Python list into the Append tool. While this seems like it should work, it doesn't. You need to format the list as a big long string. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fcString = ""
for fc in fcList:
&amp;nbsp;&amp;nbsp; fcString = fcString + fc + ";"
arcpy.Append_management(fcString[:-1], outLocation + os.sep + emptyFC, "NO_TEST")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.Append_management(str(fcList).replace(",",";")[1:-1], outLocation + os.sep + emptyFC, "NO_TEST")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:56:28 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2021-12-12T04:56:28Z</dc:date>
    <item>
      <title>Creating a python list of FCs in subdirectories and append to a FC in a FGDB</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-python-list-of-fcs-in-subdirectories/m-p/687953#M53283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need some help with the following script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os, sys

# Set local variables
outLocation = r'M:\TRIM\test.gdb\trim'
emptyFC = 'troad'

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList = []

&amp;nbsp;&amp;nbsp;&amp;nbsp; # All troad shp files in the workspace are placed into a list&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; def fcs_in_workspace(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in arcpy.ListFeatureClasses('troad*'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.append(os.path.join(workspace, fc))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ws in arcpy.ListWorkspaces():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs_in_workspace(os.path.join(workspace, ws))

&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs_in_workspace(r'M:\104a\trim\shp')
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Append the feature classes into the empty feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Append_management(fcList, outLocation + os.sep + emptyFC, "NO_TEST")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fcList

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # If an error occurred while running a tool print the messages
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What it is supposed to do is build a FC list and use that list to append all the shp files to a FC in a FGDB.&amp;nbsp; The above code works for listing all the SHP files in the interactive window, but for whatever reason the&amp;nbsp; arcpy.Append_management tool only appends the first item in the list to the File geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone have any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Adam&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jun 2011 21:37:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-python-list-of-fcs-in-subdirectories/m-p/687953#M53283</guid>
      <dc:creator>AdamInglis</dc:creator>
      <dc:date>2011-06-28T21:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python list of FCs in subdirectories and append to a FC in a FGDB</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-python-list-of-fcs-in-subdirectories/m-p/687954#M53284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are attempting to pass an actual Python list into the Append tool. While this seems like it should work, it doesn't. You need to format the list as a big long string. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fcString = ""
for fc in fcList:
&amp;nbsp;&amp;nbsp; fcString = fcString + fc + ";"
arcpy.Append_management(fcString[:-1], outLocation + os.sep + emptyFC, "NO_TEST")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.Append_management(str(fcList).replace(",",";")[1:-1], outLocation + os.sep + emptyFC, "NO_TEST")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:56:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-python-list-of-fcs-in-subdirectories/m-p/687954#M53284</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T04:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python list of FCs in subdirectories and append to a FC in a FGDB</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-python-list-of-fcs-in-subdirectories/m-p/687955#M53285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;One more way (there are probably even more):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fcString = ";".join(fcList)
arcpy.Append_management(fcString, outLocation + os.sep + emptyFC, "NO_TEST")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:56:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-python-list-of-fcs-in-subdirectories/m-p/687955#M53285</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2021-12-12T04:56:31Z</dc:date>
    </item>
  </channel>
</rss>

