AnsweredAssumed Answered

Merge_management and fieldmappings problem

Question asked by cmatthews on Feb 17, 2016
Latest reply on Feb 22, 2016 by cmatthews

I am using arcpy.Merge_management to combine 4 CSV files into SDE. I attempting to use fieldmappings to rename the field headers, and this is causing it to crash. I've not used fieldmapping with more than two datasets simaltaneously before...

 

The error is trapped by the try loop, but is returning no information. Any help would be appreciated.

 

try:

    if booContinue == True:

        fieldmappings = arcpy.FieldMappings()

        fieldmap1 = arcpy.FieldMap()

 

        fieldmappings.addTable(rg_Layer)

        fieldmappings.addTable(ox_Layer)

        fieldmappings.addTable(sn_Layer)

        fieldmappings.addTable(sp_Layer)

 

        fieldmap1.addInputField(rg_Layer,"field1")

        fieldmap1.addInputField(ox_Layer,"field1")

        fieldmap1.addInputField(sn_Layer,"field1")

        fieldmap1.addInputField(sp_Layer,"field1")

 

        fieldout1 = fieldmap1.outputField

        fieldout1.name = "PCODE"

        fieldmap1.outputField = fieldout1

 

        fieldmappings.addFieldMap(fieldmap1)

       

        arcpy.Merge_management([rg_Layer,ox_Layer,sn_Layer,sp_Layer], pc_layer, fieldMappings)

 

        msg = msg + "\n" + outname + " created"

except:

    msg = msg + "\n" + "error creating " + outname + " - " + "\n" + arcpy.GetMessages(2)

    booContinue = False

Outcomes