<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export Table with selected fields in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-table-with-selected-fields/m-p/1279681#M67446</link>
    <description>&lt;P&gt;Use the field mappings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(fc)

keepfields = ['F1','F2','F3','F4']

# Removing unwanted fields
for field in fieldmappings.fields:
    if all([not field.required, field.name not in keepfields]):
        fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex(field.name))
        
arcpy.FeatureClassToFeatureClass_conversion(fc, 'outdir', 'outname', '', fieldmappings)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2023 14:43:21 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2023-04-18T14:43:21Z</dc:date>
    <item>
      <title>Export Table with selected fields</title>
      <link>https://community.esri.com/t5/python-questions/export-table-with-selected-fields/m-p/1279671#M67444</link>
      <description>&lt;P&gt;I just need a simple sript that will copy a feature layer and convert it to a shapefile with just a four of the original field names.&amp;nbsp; I know how to do this manually but I need python script so it can automatically every morning.&amp;nbsp; I tried&amp;nbsp;arcpy.TableToTable_conversion and FeatureClassTo FeatureClass but can't seem to figure it out how to select only those field name that are required for my project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 14:30:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-table-with-selected-fields/m-p/1279671#M67444</guid>
      <dc:creator>Williams_Gregory</dc:creator>
      <dc:date>2023-04-18T14:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Export Table with selected fields</title>
      <link>https://community.esri.com/t5/python-questions/export-table-with-selected-fields/m-p/1279681#M67446</link>
      <description>&lt;P&gt;Use the field mappings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(fc)

keepfields = ['F1','F2','F3','F4']

# Removing unwanted fields
for field in fieldmappings.fields:
    if all([not field.required, field.name not in keepfields]):
        fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex(field.name))
        
arcpy.FeatureClassToFeatureClass_conversion(fc, 'outdir', 'outname', '', fieldmappings)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 14:43:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-table-with-selected-fields/m-p/1279681#M67446</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-04-18T14:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Export Table with selected fields</title>
      <link>https://community.esri.com/t5/python-questions/export-table-with-selected-fields/m-p/1279682#M67447</link>
      <description>&lt;P&gt;If it's always the same four fields, the easiest way to do it is to do it manually once, then open up your geoprocessing history and copy as a python command/send to the python window and copypaste into your project.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 14:39:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-table-with-selected-fields/m-p/1279682#M67447</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-04-18T14:39:55Z</dc:date>
    </item>
  </channel>
</rss>

