3

I try to merge all Shapefiles from one folder together into one, using this:

shapeList = arcpy.ListFeatureClasses()
print shapeList
for fc in shapeList:
    if fc == "*domain*":
         arcpy.Merge_management(shapeList, "MergeList")

But I always get this error message:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 3987, in Merge
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Datasets:
-- HERE THE LIST OF FEATURECLASSES --
does not exist or is not supported
Failed to execute (Merge).

I am sure there are only feature classes in the folder, when I try to use a Merge function I get the Error:

ERROR 000338: Inputs must be either all Feature Classes, Tables or Rasters; not mixed.
Failed to execute (Append).
Failed at Thu Jan 29 16:22:28 2015 (Elapsed Time: 0.00 seconds)

Does anybody know what's going wrong?

1

Below code works for me. I do two types of filtering (firstly select all features name start with "One" and then those features from these selected features which have word "domain" in the name) to select features and run merge operation on that features.

import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"C:\Users\USER_NAME\Documents\ArcGIS\my.gdb"
fcs = arcpy.ListFeatureClasses("One*") # select all fatures Starts with "One"
fc= []
pattern ="domain" # Merge all fetaures that have word "domain" in the name
output = "C:\Users\USER_NAME\Documents\ArcGIS\my.gdb\merged"
for i in fcs:
    if pattern in i:
        fc.append(i)
        arcpy.Merge_management(fc,output)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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