Hello
How do I match FCFrom field "Point_X" with FCTo field "PointX" before doing an arcpy.Append_management
# Create a new fieldmappings and add the two feature classes.
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(FCFrom)
fieldmappings.addTable(FCTo)
schemaType = "NO_TEST "
???? how do I match FCFrom field "Point_X" with FCTo field "PointX"
arcpy.Append_management(FCFrom, FCTo, schemaType, fieldMappings, subtype)
see the code example on field mapping here
Mapping input fields to output fields—ArcPy Get Started | ArcGIS Desktop
I want to populate the field CAPDESC with the field "CAP_DESC" .
What am I missing?
I am getting this error message :
ERROR 000800: The value is not a member of TEST | NO_TEST.
Create a new fieldmappings and add the two feature classes.
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(FCFrom)
fieldmappings.addTable(FCTo)
schemaType = "NO_TEST "
fieldmappings.replaceFieldMap(fieldmappings.findFieldMapIndex("CAPDESC"), fieldmap)
fieldmap.addInputField(FCFrom, "CAP_DESC")
fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("CAP_DESC"))
arcpy.Append_management(FCFrom, FCTo, schemaType, fieldmappings)
Jose, you have use "CAPDESC" 3 times, in the code example they used the sequence "TRACT2000", "TRACTCODE", "TRACT2000"
Code with line numbers would help
Changed the code:
fieldmap = fieldmappings.getFieldMap(fieldmappings.findFieldMapIndex("CAPDESC"))
fieldmap.addInputField(FCFrom, "CAP_DESC")
fieldmappings.replaceFieldMap(fieldmappings.findFieldMapIndex("CAPDESC"), fieldmap)
fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("CAP_DESC"))
Same error:
Failed to execute. Parameters are not valid.
ERROR 000800: The value is not a member of TEST | NO_TEST.
Failed to execute (Append).
Finally I found the error: in the variable schemaType = "NO_TEST " the string "NO_TEST " had a space at the end. I removed the space schemaType = "NO_TEST", and now it works.
#Target Layer
fieldmappings.addTable(FCto)
#Append Layer
fieldmappings.addTable(FCFrom)
schemaType = "NO_TEST"
fieldmap = fieldmappings.getFieldMap(fieldmappings.findFieldMapIndex("CAPDESC"))
fieldmap.addInputField(FCFrom, "CAP_DESC")
fieldmappings.replaceFieldMap(fieldmappings.findFieldMapIndex("CAPDESC"), fieldmap)
arcpy.Append_management(FCFrom, FCto, schemaType, fieldmappings)