AnsweredAssumed Answered

FieldMap and FieldMappings arrgh....

Question asked by jborgion on Feb 27, 2018
Latest reply on Feb 28, 2018 by jborgion

I'm trying to get FieldMappings—Help | ArcGIS Desktop  to work.  The need is to append records from one table to records of a different table with the NO_TEST option as the two don't have the same schemas.  I've tried with a table to table append, and also with a feature class to feature class append.  In both cases I can get the records from one table to append to the target table, and feature geometry to append to the target feature class.  But....  None of the attribute values come over in either case. This has to be one of the most complex processes I've ever seen, and I cannot for the life of me see where the issue is.  Below is the python script I'm using to do it; pretty much right out of the help page.  If anyone has had this work for them, perhaps your second set of eyes is what I need....


import arcpy

in_file1 = r'C:\Replicas\Replicas.gdb\MasterStreetNameFC'
#output_file = r'C:\Replicas\Replicas.gdb\CoordOverlapErrors'
output_file = r'C:\Replicas\Replicas.gdb\Points'

fm_streetname = arcpy.FieldMap()
fm_type = arcpy.FieldMap()
fm_housedir = arcpy.FieldMap()
fm_begrange = arcpy.FieldMap()
fm_endrange = arcpy.FieldMap()
fm_begcoord = arcpy.FieldMap()
fm_endcoord = arcpy.FieldMap()
fm_streetdir = arcpy.FieldMap()
fm_cityjurs = arcpy.FieldMap()
fm_zipcode = arcpy.FieldMap()
fm_oid = arcpy.FieldMap()

fms = arcpy.FieldMappings()

##s_name = 'StreetName'
##s_type = 'Type'
##s_housedir = 'HouseDir'
##s_begrange = 'BegRange'
##s_endrange = 'EndRange'
##s_begcoord = 'BegCoord'
##s_endcoord = 'EndCoord'
##s_streetdir = 'StreetDir'
##s_cityjurs = 'CityJurs'
##s_zipcode = 'ZipCode'
##s_oid = 'OBJECTID'
## These variables are commented out
## as I used the actual field names below
## thinking maybe the variables were the problem...

fm_type.addInputField(in_file1, 'Type')
fm_housedir.addInputField(in_file1, 'HouseDIr')
fm_begrange.addInputField(in_file1, 'BegRange')
fm_endrange.addInputField(in_file1, 'EndRange')
fm_begcoord.addInputField(in_file1, 'BegCoord')
fm_endcoord.addInputField(in_file1, 'EndCoord')
fm_streetdir.addInputField(in_file1, 'StreetDir')
fm_cityjurs.addInputField(in_file1, 'CityJurs')
fm_zipcode.addInputField(in_file1, 'ZipCode')
fm_oid.addInputField(in_file1, 'OBJECTID')

StreetName1 = fm_streetname.outputField
Type1 = fm_type.outputField
HouseDir1 = fm_housedir.outputField
BegRange1 = fm_begrange.outputField
EndRange1 = fm_endrange.outputField
BegCoord1 = fm_begcoord.outputField
EndCoord1 = fm_endcoord.outputField
StreetDir1 = fm_streetdir.outputField
CityJurs1 = fm_cityjurs.outputField
Zip1  = fm_zipcode.outputField
OID1 = fm_oid.outputField
StreetName2 = fm_streetname.outputField
Type2 = fm_type.outputField
HouseDir2 = fm_housedir.outputField
BegRange2 = fm_begrange.outputField
EndRange2 =  fm_endrange.outputField
BegCoord2 = fm_begcoord.outputField
EndCoord2 =  fm_endcoord.outputField
StreetDir2 = fm_streetdir.outputField
CityJurs2 = fm_cityjurs.outputField
Zip2 = fm_zipcode.outputField
OID2 = fm_oid.outputField