I'm trying to copy feature from one feature class to another with only certain fields and an SQL query. I can't seem to get the field mappings object to work right. Here is what I have:import arcpy from arcpy import env arcpy.env.overwriteOutput = True in_path =r"Database Connections/Sun120 - 5151.sde/CONVERSION." in_feature = "CPTESTPOINTINSPECTION" out_path = r"E:/Rich Anderson/CP_ReChecks/" FileGDBName = "Test.gdb" infc1 = in_path + in_feature try: fieldmappings = arcpy.FieldMappings() fieldmappings.addTable(infc1) fldmap_READING = arcpy.FieldMap() fldmap_READING.addInputField(infc1, "READING") fld_READING = fldmap_READING.outputField fld_READING.name = "READING" fldmap_READING.outputField = fld_READING fieldmappings.addFieldMap(fldmap_READING) arcpy.FeatureClassToFeatureClass_conversion(in_path + in_feature, out_path + FileGDBName, "Max_CP_Inspection_Date_Test", " \"READING\" > 85 ", fieldmappings) except Exception as e: print e
This works but just adds a new field called "READING_1" with all null values to the output feature class along with all of the other fields (including the original "READING" field and its values). How can I get the feature class to feature class tool to only copy the fields I want? I've been at this for over four hours! Thanks...