AnsweredAssumed Answered

Merge with field mapping

Question asked by CCweedcontrol on Sep 4, 2019
Latest reply on Sep 6, 2019 by CCweedcontrol

I  am trying to merge five layers into one with only three fields. The code merges the layers fine with out error but the output layer has all the layers fields and the RD_Owner field doesn't have the attributes merged. so i am guessing my fieldmapping isn't correct. I would appreciate any help.


HwyNpaPub = 'C:/Temp/HighwayDistricts.gdb/HWY1'
HwyNpaPr = 'C:/Temp/HighwayDistricts.gdb/HWY2'
HwyCan = 'C:/Temp/HighwayDistricts.gdb/HWY3'
HwyG = 'C:/Temp/HighwayDistricts.gdb/HWY4'
HwyNP = 'C:/Temp/HighwayDistricts.gdb/HWY5'

FieldMapString = '''

STREET "STREET" true true false 50 Text 0 0,First,#,{0},STREET,0,11;
ROAD_TYPE "ROAD_TYPE" true true false 70 Text 0 0,First,#,{0},ROAD_TYPE,0,11;
RD_Owner "RD_Owner" true true false 255 Text 0 0 ,Join,#, {0}, RD_Owner,-1,-1;


def Layers1(HwyNpaPub,HwyNpaPr,HwyCan,HwyG,HNP1):
    fieldmappings = arcpy.FieldMappings()
    return fieldmappings

def main(args=None):
        if args is None:
                args = sys.argv

arcpy.Merge_management([HwyNpaPub, HwyNpaPr, HwyCan, HwyG, HwyNP], 'D:/GIS Folder/HighwayDistricts.gdb/TEST', Layers1(HwyNpaPub, HwyNpaPr, HwyCan, HwyG, HwyNP))