hi guys i m doing a script in Arcgis i m new to this, i have to append some field from a table to another, i did this script in python but i have a problem when it want make the Mapping field with a field of type shape shape i mean = point, line, polygon ..
the error that i get is this one:
FieldMap: Error in adding input field to field map Failed to execute (script).
# import system modules
import arcpy, os
from arcpy import env
# get parameters
tabellaInput = arcpy.GetParameterAsText(0)
tabellaOutput = arcpy.GetParameterAsText(1)
# Set local variables
fieldMappings = arcpy.FieldMappings()
# add the table to field mapping
fieldMappings.addTable(tabellaOutput)
fieldnames = [f.name for f in arcpy.ListFields(tabellaInput)]
fieldnamesOut = [f.name for f in arcpy.ListFields(tabellaOutput)]
for elem in fieldnames:
arcpy.AddMessage(str(elem));
if str(elem) not in fieldnamesOut:
continue
#creat a field map for each field.
fldMap = arcpy.FieldMap()
fldMap.addInputField(tabellaInput,elem) # deve aggiugere questo field
# Set name of new output field
namefield = fldMap.outputField
namefield.name = elem
fldMap.outputField = namefield
# Add output field to field mappings object
fieldMappings.addFieldMap(fldMap)
schemaType = "NO_TEST"
subtype = ""
try:
# Process: Append the feature classes into feature class
arcpy.Append_management(tabellaInput, tabellaOutput, schemaType, fieldMappings, subtype)
except:
# If an error occurred while running a tool print the messages
print arcpy.GetMessages()
it dose stop inside the
for....
when come a field of type shape
infact if i add inside the
for
the following line of code:
if elem == 'Shape':
continue
it works good .. this is pretty strange. Another things is this: I have more fields in the input table then the target table so why in the target i don't see all the fields of the input table? i should do a merge e not the append??