Question about Python's merge_Management inputs

Discussion created by GlennK on Feb 1, 2012
Latest reply on Feb 1, 2012 by mzcoyle
ArcView 10.0 SP2
Windows XP Pro SP3

I need to write a script that merges three shapefiles. The shapefile inputs and the output shapefile all need to be user chosen parameters.

Currently I have the first parameter set as a Table View type so that all three shapefiles can be added at once, as opposed to three separate parameters. Is this the best way to go? I noticed these parameter values are different depending on if I choose layers already in my map versus browsing to the folder(s) and adding them that way.

As to field mapping, I want the output to be an aggregate of all the fields in the three input shapefiles. Since this is the case, can I just omit field mapping?

The code below is simple and incomplete, but should give a good idea of what I'm doing wrong. :p

# Import arcpy module
import arcpy

# Script arguments
inShapes = arcpy.GetParameterAsText(0)      # delimited list of the three shapefile inputs [Table View]
outName = arcpy.GetParameterAsText(1) + ".shp"    # output shapefile name [String]
outFolder = arcpy.GetParameterAsText(2)      # output folder [Folder]

arcpy.AddMessage("\n" + "\n" + inShapes + "\n" + "\n")  # visual feedback, remove when this works

# didn't know what the heck I was doing here. Can skip?
#fMappings = arcpy.CreateObject("FieldMappings")
#fMap1 = arcpy.CreateObject("FieldMap")

outputdata = outFolder + "\\" + outName
arcpy.AddMessage(outputdata)        # visual feedback, remove when this works
arcpy.Merge_management([inShapes], outputdata)

arcpy.AddMessage("\n" + "\n" + "\n")