AnsweredAssumed Answered

Deleting Global ID field

Question asked by lindsay.raabe_FPCWA on Nov 20, 2019
Latest reply on Nov 25, 2019 by rvburton

I've got a feature class that I am trying to remove the Global ID and editor information fields from. So far, the best way I can figure out is to create a new version of the feature class without the fields and append the data across. I've tried the following code I found online and tweaked, but am stuck on the field mapping. 


The input FC is "Prod_Temp" and I want the output to be "Prod_Sync". The fields listed in myfields are the fields in "Prod_Temp" that I want to retain. When I run the script, it complains about something around Line 10. I think I'm misunderstanding the input option for map.addInputField(existingFC, field). 


Any pointers?


# feature class I want to copy from
existingFC = (r"W:\TEMP\Prod_Temp.gdb\Prod_Temp")
# list of fields I want to keep (capitalization counts!)
myfields = ['FPCBusinessArea', 'Location', 'OpType', 'OperationStatus', 'Contractor', 'ContractorSupervisor', 'SupervisorPhone', 'FPCOIC', 'FPCOICPhone', 'Machinery', 'Comments', ]
# create an empty field mapping object
mapS = arcpy.FieldMappings()
# for each field, create an individual field map, and add it to the field mapping object
for field in myfields :
    map = arcpy.FieldMap()
    map.addInputField(existingFC, field)
# copy the feature class using the fields you want
Prod_Sync = arcpy.FeatureClassToFeatureClass_conversion(existingFC, r"W:\TEMP\Prod_Sync.gdb", "Prod_Sync", "", mapS)