AnsweredAssumed Answered

FeatureClassToFeatureClass_conversion with only certain fields

Question asked by emilharold on Dec 13, 2013
Latest reply on Dec 16, 2013 by emilharold
Greetings,

I am using FeatureClassToFeatureClass_conversion to export a new feature based on a selection. I would only like to carry over certain fields. Is this something that can be done?

It looks like it is done through the FieldMap parameter but I have never worked with FieldMap objects...

EDIT: I've written this...

fieldmappings = arcpy.FieldMap ()
fieldmappings.addInputField(thePoint, "POINTGUIDt")
fieldmappings.addInputField(thePoint, "S_FILE")
fieldmappings.addInputField(thePoint, "LINE_NBR")

then try to use it here:

arcpy.FeatureClassToFeatureClass_conversion (thePoint, outDatabase, "PPMD_04V1i_" + envelopePolyTrim,"",fieldmappings)

and get this:

Traceback (most recent call last):
  File "C:\E1B8\ScriptTesting\SelectbyAttributeAndExport\Actual\ActualSelectbyAttributeAndExport.py", line 61, in <module>
    arcpy.FeatureClassToFeatureClass_conversion (thePoint, outDatabase, "PPMD_04V1i_" + envelopePolyTrim,"",fieldmappings)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\conversion.py", line 1547, in FeatureClassToFeatureClass
    raise e
RuntimeError: Object: Error in executing tool

Am I close? Thanks :)

Outcomes