This is my first whack at field mapping. I've looked through the history of posts on this issue and have implemented the solutions (as far as I understand them). But it's not working for me.
Basically, when I assign field = fieldMap.outputField, the field variable then references a describe field object object instead of a field object. I can field.name = "NAME" but when I apply that to the field map via fieldMap.outputField(file, field) it bombs.
It's my understanding that fieldMap.outputField should return a field object, but for some reason I'm getting a describe object. Any help would be welcome!
# input files and workspaces
fgdb = r"N:\GDB\GDB.gdb"
HDMSfile = r"N:\GDB\plants\HDMS.shp"
GDBfile = r"N:\GDB\GDB.gdb\Occurrence_scriptgen"
sppfile = r"N:\GDB\GDB.gdb\SpeciesList"
# environments set
arcpy.env.workspace = fgdb
# field map preparation
fieldmappings = arcpy.FieldMappings()
fm_SiteIdHDMS = arcpy.FieldMap()
print "Field map prepared."
fm_SiteIdHDMS.addInputField(HDMSfile, "EO_ID")
fld_SiteIdHDMS = fm_SiteIdHDMS.outputField
fld_SiteIdHDMS.name = "SiteID_HDMS"
print fld_SiteIdHDMS.name
print fld_SiteIdHDMS
fm_SiteIdHDMS.outputField(GDBfile, fld_SiteIdHDMS)
Python Interpreter Results:
Field map prepared.
SiteID_HDMS
<geoprocessing describe field object object at 0x16A18F80>
Traceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "N:\RarePlants_CNF\PythonScripts\HDMS_to_RarePlantOccurrence.py", line 46, in <module>
fm_SiteIdHDMS.outputField(CNFfile, fld_SiteIdHDMS)
TypeError: 'Field' object is not callable
(line 46 corresponds to line 20 of the above scrippet)