replaceFieldMap() appears broken in arcpy

Discussion created by sjones on Jul 17, 2011
Latest reply on Jul 21, 2011 by sjones
ArcPy People:

The scenario is a simple one. I want to join a table view to a feature layer, clean up the output fields so the field name does not contain the table name, and export the contents to a file geodatabase using either FeatureClassToFeatureClass_management or TableToTable_management.

The python/arcpy script crashes out when it encounters either of these functions with the fieldMappings object as a parameter.

I can remove unwanted fields from the fieldMappings using removeFieldMap(). But when I replace a fieldMap in the fieldMappings with a newly formatted field name, the replaceFieldMap() command causes the script to fail.

We can easily rename output fields using the Geoprocessing Tools out of ArcCatalog and Model Builder. The problem is with arcpy and the replaceFieldMap().

My workaround thus far is to use layerfiles with a pre canned set of output field names.

It would be nice to have something a little more elegant.

(I am not sure if ESRI have raised this as a bug, local support here will try and recreate the issue using their own data and scripts)

Susan Jones
GIS Consultant
Spatial Logic Ltd