Append feature classes using Python

3512
16
Jump to solution
07-05-2018 06:53 AM
EdwardGlover1
New Contributor III

I have 5 point feature classes that I am trying to append into a point feature class.  I get the following error when I attempt to run the code shown below: 

Failed to execute. Parameters are not valid.
ERROR 000338: Inputs must be either all Feature Classes, Tables or Rasters; not mixed.
Failed to execute (Append).

I can run the append successfully when using the Append tool in Desktop.  I am at a loss as to why the code throws the error.  Any insight would be very much appreciated.

# Import arcpy module
import arcpy
import os


SDE = r'C:\Development\py1\gis@GISDEV02 frt (emadb51 DC) - VegD2.sde'

# Set local variables
FC_Inven = os.path.join(SDE, 'GIS.VegD_Inventory')
FC_Unit = os.path.join(SDE, 'GIS.VegD_Unit_Inventory')
FC_Hrly2 = os.path.join(SDE, 'GIS.VegD_Hourly_Inventory')
FC_Hrly = os.path.join(SDE, 'GIS.VegD_Hourly')
FC_Flat = os.path.join(SDE, 'GIS.VegD_FlatRate')
FC_Matrix = os.path.join(SDE, 'GIS.VegD_Matrix')
schemaType = "NO_TEST"
fieldMappings = ""
subtype = ""

try:

    # Process: Truncate Table
    arcpy.TruncateTable_management(FC_Inven)

    # Process: Append the feature classes into the empty feature class
    arcpy.Append_management('FC_Unit; FC_Hrly2; FC_Hrly; FC_Flat; FC_Matrix', FC_Inven, schemaType,    fieldMappings, subtype)

except Exception as err:
print(err.args[0])

Tags (2)
1 Solution

Accepted Solutions
EdwardGlover1
New Contributor III

The error was caused by the Append input being interpreted as a string as opposed to variables.  Below is syntax that worked for me.  Thanks to all for your assistance with my issue!

arcpy.Append_management('"' + FC_Unit + ';' + FC_Hrly2 + ';' + FC_Hrly + ';' + FC_Flat + ';' + FC_Matrix + '"', FC_Inven, schemaType,    fieldMappings, subtype)

View solution in original post

0 Kudos
16 Replies
DanPatterson_Retired
MVP Esteemed Contributor

have you tried a comma delimited list as inputs rather than a semi-colon delimited string? 

The help isn't clear as to what is acceptable

http://pro.arcgis.com/en/pro-app/tool-reference/data-management/append.htm

0 Kudos
EdwardGlover1
New Contributor III

Thanks for the suggestion. I just tried a comma delimited list and got the same error message.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

What about:

arcpy.Append_management( ','.join(FC_Unit, FC_Hrly2, FC_Hrly, FC_Flat, FC_Matrix), FC_Inven, schemaType,    fieldMappings, subtype)
0 Kudos
EdwardGlover1
New Contributor III

I tried this and got the following message in the python interpreter: join() takes exactly one argument (5 given)

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Ah, sorry, forgot to wrap them in a list.

arcpy.Append_management( ','.join([FC_Unit, FC_Hrly2, FC_Hrly, FC_Flat, FC_Matrix]), FC_Inven, schemaType,    fieldMappings, subtype)
0 Kudos
EdwardGlover1
New Contributor III

I get the same error.  I am going to copy the 6 feature classes into a fgdb and run the script on it to see if the error persists.  Thanks for taking the time to offer some assistance.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Same error?  Did you re-copy and paste my code?  The square brackets I added to the code should have made the join error go away.  There still may be an error, I am just surprised you are getting a join error still.

0 Kudos
EdwardGlover1
New Contributor III

Sorry for my lack of clarity.  The "same error" I was referring to is based on my original post.  Your revision did address the argument message when I attempted to run your initial line of code.

0 Kudos
Juan_ManuelAngel_Cuartas
New Contributor II

Try to set the arcpy.env.workspace with the SDE path and just call the name of the FC in the list.

0 Kudos