<?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: How to Delete Fields from File Geodatabase Table using ArcPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210228#M16281</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am working with a similar challenge.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to keep the fields one wants rather than remove unwanted fields? If so, could one then create a table that is a subset of the original and save it to a new folder with a new name?&lt;/P&gt;&lt;P&gt;I will read about Field Mapping. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, would it be better to manage the fields when they are shapefiles or convert the .shp to a .xls first?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Doug&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Jul 2017 17:30:31 GMT</pubDate>
    <dc:creator>DougHaller1</dc:creator>
    <dc:date>2017-07-17T17:30:31Z</dc:date>
    <item>
      <title>How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210220#M16273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm wondering if someone can help. I'm trying to write a python script that will:&lt;BR /&gt;1. Create a buffer&lt;BR /&gt;2. Use the buffer to query a feature class&lt;BR /&gt;3. Export a file geodatabase table of only the selected features&lt;BR /&gt;4. Delete unwanted fields&lt;BR /&gt;5. Export the cleaned up table to excel&lt;/P&gt;&lt;P&gt;Steps 1-3 work fine. I can even get that table to export to excel. I am having difficulty with step 4. I've tried various methods to do this but to no avail. Attached is a copy of the script. The Workspace, feature to buffer and proj_prefix are all input parameters not included in the snippet.&lt;/P&gt;&lt;P&gt;Thanks for any help in advance.&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2017 20:43:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210220#M16273</guid>
      <dc:creator>JohnPapageorgiou</dc:creator>
      <dc:date>2017-01-23T20:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210221#M16274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hint: use &lt;A href="https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?sr=search&amp;amp;searchId=cb116ac2-10fd-404c-bd11-8ff900abd957&amp;amp;searchIndex=0"&gt;https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?sr=search&amp;amp;searchId=cb116ac2-10fd-404c-bd11-8ff900abd957&amp;amp;searchIndex=0&lt;/A&gt;‌ to make it easier for people to read you code and comment, versus having to open and view a snapshot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand correctly, you do not want to include some fields in the outputted Excel file.&amp;nbsp; Try including the Fields you want to include using the Field Mapping.&amp;nbsp; It is sometimes easier to run it manually first, then copy the python snippet from the results tab to see the format it wants.&lt;/P&gt;&lt;P&gt;Table To Table (Conversion)&lt;/P&gt;&lt;DIV&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;TableToTable_conversion (in_rows, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})&lt;/DIV&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=""&gt;Parameter&lt;/TD&gt;&lt;TD class=""&gt;Explanation&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;/DIV&gt;&lt;P&gt;A couple other possibilities.....if your are trying to delete required fields or the file has a lock&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2017 21:09:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210221#M16274</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2017-01-23T21:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210222#M16275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/delete-field.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/delete-field.htm"&gt;Delete Field—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you sure the fields exist in the file you are creating? Case is important as well. you may need to add a check to see if the field exists prior to deleting it&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/field.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/field.htm"&gt;Field—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2017 21:19:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210222#M16275</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-01-23T21:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210223#M16276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;The fields are making it to the output table I create. &amp;nbsp;Is that what you mean? &amp;nbsp;Can you elaborate on "add a check", do you mean create a script that list the fields?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2017 21:55:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210223#M16276</guid>
      <dc:creator>JohnPapageorgiou</dc:creator>
      <dc:date>2017-01-23T21:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210224#M16277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rebecca,&lt;/P&gt;&lt;P&gt;I'm looking into the field_mapping option right now. &amp;nbsp;I'll keep your hint in mind for the next time I post a question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2017 21:57:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210224#M16277</guid>
      <dc:creator>JohnPapageorgiou</dc:creator>
      <dc:date>2017-01-23T21:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210225#M16278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can get the field object and their names readily&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;field_names &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;featureclass&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you have those, you should check that the field names that you want to delete are actually there&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How about an example to demonstrate what I mean&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; del_flds &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ArEa"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"AREA"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Area"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NotArea"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; fld_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Area"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"length"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"etc"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; to_delete &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; del_flds &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fld_list&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; to_delete
&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Area'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can use the DeleteField&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/delete-field.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/delete-field.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Delete Field—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:22:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210225#M16278</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T10:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210226#M16279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your problem lies in line 161 where you are defining the delete table - you are using the same syntax as for the TableToTable conversion tool, which is incorrect. &amp;nbsp;I believe it should be&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;countyTable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"gis_data.gdb/"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; proj_prefix &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"_ca_counties"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jan 2017 08:20:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210226#M16279</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2017-01-24T08:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210227#M16280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone for your contributions! &amp;nbsp;FC Basson your suggestion solved the problem. &amp;nbsp;Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jan 2017 16:50:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210227#M16280</guid>
      <dc:creator>JohnPapageorgiou</dc:creator>
      <dc:date>2017-01-24T16:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Fields from File Geodatabase Table using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210228#M16281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am working with a similar challenge.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to keep the fields one wants rather than remove unwanted fields? If so, could one then create a table that is a subset of the original and save it to a new folder with a new name?&lt;/P&gt;&lt;P&gt;I will read about Field Mapping. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, would it be better to manage the fields when they are shapefiles or convert the .shp to a .xls first?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Doug&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:30:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-delete-fields-from-file-geodatabase-table/m-p/210228#M16281</guid>
      <dc:creator>DougHaller1</dc:creator>
      <dc:date>2017-07-17T17:30:31Z</dc:date>
    </item>
  </channel>
</rss>

