1

I have two GDB's that are the same schema. One is a master GDB that we are appending other individual GDB's into. The GDB's contain several points, polys, lines, and tables as well as 2 datasets with additional feature classes. I've started with a bit of code I found from https://community.esri.com/thread/105313#comments and modified the multiple GDB's to a single. The code appears to do what I want; append feature classes that are within the datasets to the master and append all root feature classes into the master.

When I run the script I get the error

Traceback (most recent call last): File "C:\Python27\Temp\append.py", line 20, in arcpy.Append_management(appendinput,GDBD+'/'+fcr,"TEST") File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 3995, in Append raise e ExecuteError: 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).

Since the code specifically lists only feature classes, I'm not sure where the mixed inputs is coming from as tables should not be included. How can I adjust this code? (I'm new to python and coding in general)

import arcpy  
from arcpy import env  
##Destination GDB  
GDBD="C:\Python27\Temp\GLOBAL_GEODATABASE.gdb"  
##List of Origin GDB  
GDBS="C:\Python27\Temp\UPRR_CaliforniaModel_20170130_1.gdb"  
##Set Environment  
arcpy.env.workspace=GDBD  
##Get List of FDS  
FDS=arcpy.ListDatasets()  
##Get List of Root Feature Classes  
ROOTFCS=arcpy.ListFeatureClasses("","POLYGON")  

##Append elements in Root Feature Classes  
for fcr in ROOTFCS:  
    appendinput=[]  
    for FCI in GDBS:  
        appendinput.append(FCI+"/"+fcr)  
    ##print appendinput  
    arcpy.Append_management(appendinput,GDBD+'/'+fcr,"TEST")  

##Append elements of Feature Classes inside Feature Datasets  
for FD in FDS:  
    for FC in arcpy.ListFeatureClasses("*","POLYGON",FD):  
        appendinput2=[]  
        for FCI2 in GDBS:  
                appendinput2.append(FCI2+"/"+FC)  
        ##print appendinput2  
        arcpy.Append_management(appendinput2,GDBD+'/'+FC,"TEST")

1 Answer 1

3

Your script wants the variable GDBS to be a list. It's a string. This is causing parsing issues.

GDBD="C:\Python27\Temp\GLOBAL_GEODATABASE.gdb"  

Strings can be parsed just like lists, one character at a time:

>>> for g in "ABC":
    print g


A
B
C
>>> 

This is what is happening with the variable GDBS here:

for FCI in GDBS:  
    appendinput.append(FCI+"/"+fcr)  

Change the string into a list.

>>> for g in ["ABC"]:
    print g


ABC
>>> 

Or, in your case:

##List of Origin GDB  
GDBS= [r"C:\Python27\Temp\UPRR_CaliforniaModel_20170130_1.gdb"]

Note the r at the start of the string. This is a raw string. File paths generally need the r.

GDBD=r"C:\Python27\Temp\GLOBAL_GEODATABASE.gdb" 
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.