adaminglis

Creating a python list of FCs in subdirectories and append to a FC in a FGDB

Discussion created by adaminglis on Jun 28, 2011
Latest reply on Jun 29, 2011 by lpugh01
I need some help with the following script:

import arcpy, os, sys

# Set local variables
outLocation = r'M:\TRIM\test.gdb\trim'
emptyFC = 'troad'

try:
    fcList = []

    # All troad shp files in the workspace are placed into a list   
    def fcs_in_workspace(workspace):
      arcpy.env.workspace = workspace
      for fc in arcpy.ListFeatureClasses('troad*'):
        fcList.append(os.path.join(workspace, fc))
        
      for ws in arcpy.ListWorkspaces():
        fcs_in_workspace(os.path.join(workspace, ws))

    fcs_in_workspace(r'M:\104a\trim\shp')
    

    # Process: Append the feature classes into the empty feature class
    arcpy.Append_management(fcList, outLocation + os.sep + emptyFC, "NO_TEST")
    print fcList

except:
    # If an error occurred while running a tool print the messages
    print arcpy.GetMessages()


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.  The above code works for listing all the SHP files in the interactive window, but for whatever reason the  arcpy.Append_management tool only appends the first item in the list to the File geodatabase.


Anyone have any suggestions?

Thanks,

Adam

Outcomes