Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Field mappings object not functioning with Merge_management

$
0
0

I’m trying to limit the number of fields when I perform a merge to two. Below is the script I have created to do so. However, the merged feature class carries over all fields, despite my use of a fieldmappings object.

di is a dictionary with a shape type (“polyline”, “polygon”, etc) as its key, and a python list of feature classes as its value. Any ideas?

relevant code:

fms = FieldMappings()
jnFm = FieldMap()
sourceFm = FieldMap()
jnFm.addInputField(fc, jobField)
sourceFm.addInputField(outFcFullPath, "FC_SOURCE")
fms.addFieldMap (jnFm)
fms.addFieldMap (sourceFm)

print "nMerging"
for shapeType in di:
    featureClasses = di[shapeType]
    mergeFC = os.path.join (outGDB, "All_" + shapeType)
    Merge_management (featureClasses, mergeFC, fms)
    print "Created: All_" + shapeType

Viewing all articles
Browse latest Browse all 767

Trending Articles