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?
<SPAN class="comment token"># feature class I want to copy from</SPAN>
existingFC <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"W:\TEMP\Prod_Temp.gdb\Prod_Temp"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># list of fields I want to keep (capitalization counts!)</SPAN>
myfields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'FPCBusinessArea'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Location'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'OpType'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'OperationStatus'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Contractor'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ContractorSupervisor'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'SupervisorPhone'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'FPCOIC'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'FPCOICPhone'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Machinery'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Comments'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># create an empty field mapping object</SPAN>
mapS <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>FieldMappings<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># for each field, create an individual field map, and add it to the field mapping object</SPAN>
<SPAN class="keyword token">for</SPAN> field <SPAN class="keyword token">in</SPAN> myfields <SPAN class="punctuation token">:</SPAN>
map <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>FieldMap<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
map<SPAN class="punctuation token">.</SPAN>addInputField<SPAN class="punctuation token">(</SPAN>existingFC<SPAN class="punctuation token">,</SPAN> field<SPAN class="punctuation token">)</SPAN>
mapS<SPAN class="punctuation token">.</SPAN>addFieldMap<SPAN class="punctuation token">(</SPAN>map<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># copy the feature class using the fields you want</SPAN>
Prod_Sync <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>FeatureClassToFeatureClass_conversion<SPAN class="punctuation token">(</SPAN>existingFC<SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">"W:\TEMP\Prod_Sync.gdb"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Prod_Sync"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> mapS<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>