<?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: Delete column before exporting to excel in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655405#M51052</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On the topic of exporting to Excel, or really exporting to anything, ArcGIS is &lt;SPAN style="text-decoration: underline;"&gt;very&lt;/SPAN&gt; stubborn about including ObjectID fields.&amp;nbsp; I have tried numerous ways to delete or hide the ObjectID field before exporting, but the tools either ignore the changes or throw an error.&amp;nbsp; One approach I have found uses &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-query-table.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Make Table Query&lt;/A&gt;, but it only works with enterprise and file geodatabases (and personal geodatabases with ArcMap/ArcCatalog) since the tool only works with those types of geodatabases.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; fc = # feature class or table in enterprise or file geodatabase
&amp;gt;&amp;gt;&amp;gt; desc = arcpy.Describe(fc)
&amp;gt;&amp;gt;&amp;gt; flds = [fld.name for fld in desc.fields]
&amp;gt;&amp;gt;&amp;gt; if desc.hasOID:
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds.remove(desc.OIDFieldName)
&amp;gt;&amp;gt;&amp;gt; arcpy.MakeQueryTable_management(fc, "tmp_view", "NO_KEY_FIELD", "", flds)
&amp;lt;Result 'tmp_view'&amp;gt;
&amp;gt;&amp;gt;&amp;gt; arcpy.TableToExcel_conversion("tmp_view", r"C:\tmp\fc_dump.xls")
&amp;lt;Result 'C:\\tmp\\fc_dump.xls'&amp;gt;
&amp;gt;&amp;gt;&amp;gt; arcpy.Delete_management("tmp_view")
&amp;lt;Result 'true'&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT:&amp;nbsp; Added a comment regarding personal geodatabase support when using ArcMap/ArcCatalog.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:45:44 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2021-12-12T03:45:44Z</dc:date>
    <item>
      <title>Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655398#M51045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script that creates a excel file but i need it to delete the "OID" field prior to exporting to excel, is this possible or does it have to be done after the export?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried the following, it runs fine and i don't get error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Process: Make Feature Layer (2)
arcpy.MakeFeatureLayer_management("In_memory\Blah", "In_memory\Blah3")

#fields = arcpy.ListFields("In_memory\Blah3", "OID")
#if len(fields) != 1:
#&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DeleteField_management("OID")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
fields = [f.name for f in arcpy.ListFields("In_memory\Blah3")]

for i,f in enumerate(fields):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if f == 'OID':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del fields&lt;I&gt;&lt;/I&gt;

# Process: Table Select
arcpy.TableToExcel_conversion("In_memory\Blah3",Listing_xls)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:45:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655398#M51045</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-12T03:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655399#M51046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If it works and doesn't export the field, I am not sure what the question is&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2016 16:16:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655399#M51046</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-29T16:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655400#M51047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to delete the "OID" column prior to exporting the layers attribute to excel, but i am not sure if it's possible during the export or after. The code i posted runs but the "OID" does not get deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2016 16:43:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655400#M51047</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2016-04-29T16:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655401#M51048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;given it is OID, that suggests a shapefile which requires a minimum of 3 fields to exist, perhaps that is limiting the deletion.&amp;nbsp; A sad workaround would be to export the table to another standalone table, delete the field then export to excel..&amp;nbsp; I doubt much would be gained, but it might work.&amp;nbsp; deleting in excel would be a quicker option...leaving it alone would cause no harm.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655401#M51048</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-29T17:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655402#M51049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ya i could leave it, doesn't hurt but just wondered if it was possible and if it was how to do it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2016 18:18:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655402#M51049</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2016-04-29T18:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655403#M51050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 20px 0; font-style: inherit; font-size: 15px; font-family: inherit;"&gt;You could use&lt;/P&gt;&lt;P style="font-style: inherit; font-family: inherit;"&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fpypi.python.org%2Fpypi%2FXlsxWriter" rel="nofollow" style="font-style: inherit; font-family: inherit; color: #287433;" target="_blank"&gt;XlsxWriter 0.8.5 : Python Package Index&lt;/A&gt;&lt;/P&gt;&lt;P style="font-style: inherit; font-family: inherit;"&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fopenpyxl.readthedocs.org%2Fen%2Fdefault%2F" rel="nofollow" style="font-style: inherit; font-family: inherit; color: #287433;" target="_blank"&gt;openpyxl - A Python library to read/write Excel 2010 xlsx/xlsm files — openpyxl 2.3.5 documentation&lt;/A&gt;&lt;/P&gt;&lt;P style="font-style: inherit; font-family: inherit;"&gt;if you want to do imports of packages or have newer versions of python&lt;/P&gt;&lt;P style="font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;P style="font-style: inherit; font-family: inherit;"&gt;Darren gave an example in this thread &lt;A _jive_internal="true" href="https://community.esri.com/message/604114#comment-604114" title="https://community.esri.com/message/604114#comment-604114"&gt;https://community.esri.com/message/604114#comment-604114&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="font-color-meta jive-comment-actions clearfix" data-comment-id="604114" style="font-style: inherit; font-size: 0.8571rem; font-family: inherit; color: #8b8b8b;"&gt;&lt;SPAN class="j-tlo-helpful-controls" style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2016 19:19:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655403#M51050</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-29T19:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655404#M51051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On a side note, if you haven't run into problems already, you likely will with how paths are being defined.&amp;nbsp; In the posted script, in-memory paths are being defined using single backslashes.&amp;nbsp; In Python, backslashes are escape characters:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="padding-left: 60px;"&gt;&lt;P style="font-size: 24px;"&gt;2.4.1. String literals&lt;A href="https://docs.python.org/2/reference/lexical_analysis.html#string-literals" style="padding: 0px 4px; color: #c60f0f; font-size: 0.8em;" title="Permalink to this headline"&gt; ¶ &lt;/A&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P style="text-align: justify; color: #000000; text-indent: 0px;"&gt;In plain English: String literals can be enclosed in matching single quotes (&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'&lt;/SPAN&gt;&lt;/CODE&gt;) or double quotes (&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;"&lt;/SPAN&gt;&lt;/CODE&gt;). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;EM&gt;triple-quoted strings&lt;/EM&gt;). The backslash (&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;\&lt;/SPAN&gt;&lt;/CODE&gt;) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'r'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;or&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'R'&lt;/SPAN&gt;&lt;/CODE&gt;; such strings are called&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;EM class="dfn"&gt;raw strings&lt;/EM&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;and use different rules for interpreting backslash escape sequences. A prefix of&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'u'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;or&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'U'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;makes the string a Unicode string. Unicode strings use the Unicode character set as defined by the Unicode Consortium and ISO 10646. Some additional escape sequences, described below, are available in Unicode strings. A prefix of&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'b'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;or&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'B'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;is ignored in Python 2; it indicates that the literal should become a bytes literal in Python 3 (e.g. when code is automatically converted with 2to3). A&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'u'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;or&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'b'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;prefix may be followed by an&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'r'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;prefix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify; color: #000000; text-indent: 0px;"&gt;In triple-quoted strings, unescaped newlines and quotes are allowed (and are retained), except that three unescaped quotes in a row terminate the string. (A “quote” is the character used to open the string, i.e. either&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;or&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;"&lt;/SPAN&gt;&lt;/CODE&gt;.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify; color: #000000; text-indent: 0px;"&gt;Unless an&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'r'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;or&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'R'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;prefix is present, escape sequences in strings are interpreted according to rules similar to those used by Standard C. The recognized escape sequences are:&lt;/P&gt;&lt;TABLE border="1" class="docutils" style="border: 0px solid #ddccee; color: #000000; text-indent: 0px;"&gt;&lt;THEAD valign="bottom"&gt;&lt;TR class="row-odd"&gt;&lt;TH class="head" style="padding: 2px 5px; text-align: center; border-top-color: #ccaacc; border-top-width: 1px; border-top-style: solid; background-color: #eeddee;"&gt;Escape Sequence&lt;/TH&gt;&lt;TH class="head" style="padding: 2px 5px; text-align: center; border-top-color: #ccaacc; border-top-width: 1px; border-top-style: solid; background-color: #eeddee;"&gt;Meaning&lt;/TH&gt;&lt;TH class="head" style="padding: 2px 5px; text-align: center; border-top-color: #ccaacc; border-top-width: 1px; border-top-style: solid; background-color: #eeddee;"&gt;Notes&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY valign="top"&gt;&lt;TR class="row-even"&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;\newline&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;Ignored&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class="row-odd"&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;\\&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;Backslash (&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;\&lt;/SPAN&gt;&lt;/CODE&gt;)&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class="row-even"&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;\'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;Single quote (&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;'&lt;/SPAN&gt;&lt;/CODE&gt;)&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class="row-odd"&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;\"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;Double quote (&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;"&lt;/SPAN&gt;&lt;/CODE&gt;)&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class="row-even"&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;CODE class="docutils literal" style="padding: 0px 1px; font-size: 0.95em; background-color: #ecf0f3;"&gt;&lt;SPAN class="pre"&gt;....&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;....&lt;/TD&gt;&lt;TD style="padding: 2px 5px; text-align: left; background-color: #eeeeff;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I don't think the script is doing what you think it is doing with regard to the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-feature-layer.htm"&gt;Make Feature Layer &lt;/A&gt;tool.&amp;nbsp; The second argument of the Make Feature Layer tool is the "name of the feature layer to be created," just a name, not a path.&amp;nbsp; On Line 02, you aren't actually storing the feature layer in-memory, you are simply creating a feature layer with "In_memory" as part of its name.&amp;nbsp; Although taking such an approach works, it is bound to cause confusion using names that resemble paths when in fact they aren't paths.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 May 2016 16:28:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655404#M51051</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-05-01T16:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655405#M51052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On the topic of exporting to Excel, or really exporting to anything, ArcGIS is &lt;SPAN style="text-decoration: underline;"&gt;very&lt;/SPAN&gt; stubborn about including ObjectID fields.&amp;nbsp; I have tried numerous ways to delete or hide the ObjectID field before exporting, but the tools either ignore the changes or throw an error.&amp;nbsp; One approach I have found uses &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-query-table.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Make Table Query&lt;/A&gt;, but it only works with enterprise and file geodatabases (and personal geodatabases with ArcMap/ArcCatalog) since the tool only works with those types of geodatabases.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; fc = # feature class or table in enterprise or file geodatabase
&amp;gt;&amp;gt;&amp;gt; desc = arcpy.Describe(fc)
&amp;gt;&amp;gt;&amp;gt; flds = [fld.name for fld in desc.fields]
&amp;gt;&amp;gt;&amp;gt; if desc.hasOID:
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds.remove(desc.OIDFieldName)
&amp;gt;&amp;gt;&amp;gt; arcpy.MakeQueryTable_management(fc, "tmp_view", "NO_KEY_FIELD", "", flds)
&amp;lt;Result 'tmp_view'&amp;gt;
&amp;gt;&amp;gt;&amp;gt; arcpy.TableToExcel_conversion("tmp_view", r"C:\tmp\fc_dump.xls")
&amp;lt;Result 'C:\\tmp\\fc_dump.xls'&amp;gt;
&amp;gt;&amp;gt;&amp;gt; arcpy.Delete_management("tmp_view")
&amp;lt;Result 'true'&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT:&amp;nbsp; Added a comment regarding personal geodatabase support when using ArcMap/ArcCatalog.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:45:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655405#M51052</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T03:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655406#M51053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course, none of us have asked why the H you would want to export it to excel in the first place &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 May 2016 21:13:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655406#M51053</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-01T21:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655407#M51054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua thanks for the great info. I have made adjustments to move the feature layer to a gdb. The code you provided did remove the OID fields but i am now suck with Shape_Length and Shape_Area fields, what would be the correct syntax to remove the OID, Shape_Length and Shape_Area fields?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tired the following but got an error on line 7.&lt;/P&gt;&lt;P&gt;if desc.hasShape_Length:&lt;/P&gt;&lt;P&gt;AttributeError: DescribeData: Method hasShape_Length does not exist&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc = "C:/Temp/Default.gdb/Blah"&amp;nbsp; 
desc = arcpy.Describe(fc)&amp;nbsp; 
flds = [fld.name for fld in desc.fields]
if desc.hasOID:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds.remove(desc.OIDFieldName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
if desc.hasShape_Length:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds.remove(desc.Shape_LengthFieldName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
if desc.hasShape_Area:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds.remove(desc.Shape_AreaFieldName) 
arcpy.MakeQueryTable_management(fc, "tmp_view", "NO_KEY_FIELD", "", flds)&amp;nbsp; 
#Result 'tmp_view'&amp;nbsp; 
arcpy.TableToExcel_conversion("tmp_view", r"C:/Temp/fc_dump.xls")&amp;nbsp; 
#Result 'C:/tmp/fc_dump.xls'
arcpy.Delete_management("tmp_view")&amp;nbsp; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;This script generates a mailing list for notifications and the office software uses Excel file to generate mailing stickers. once I generate the list i have to open up excel and delete the OID, Shape_Length and Shape_Area fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:45:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655407#M51054</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-12T03:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655408#M51055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using mail merge it will hurt nothing to leave the OID field in place.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 16:21:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655408#M51055</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-05-02T16:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655409#M51056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;Something like this might work.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Get list of usable field names (exclude OID and SHAPE fields)
fieldNames = [
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.name for f in arcpy.ListFields(inputTable)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.type != "Geometry" and f.editable == True
]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655409#M51056</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-12T03:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655410#M51057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;so you are saying switching to a gdb increases the number of fields you need to delete?? excel macro time &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 17:10:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655410#M51057</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-02T17:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655411#M51058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc = "C:/Temp/Default.gdb/Blah"&amp;nbsp;&amp;nbsp; 
desc = arcpy.Describe(fc)
flds = [fld.name for fld in desc.fields]
flds_remove = [desc.OIDFieldName,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc.shapeFieldName,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc.areaFieldName,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc.lengthFieldName]
for fld in flds_remove:
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds.remove(fld)
arcpy.MakeQueryTable_management(fc, "tmp_view", "NO_KEY_FIELD", "", flds)&amp;nbsp;&amp;nbsp; 
#Result 'tmp_view'&amp;nbsp;&amp;nbsp; 
arcpy.TableToExcel_conversion("tmp_view", r"C:/Temp/fc_dump.xls")&amp;nbsp;&amp;nbsp; 
#Result 'C:/tmp/fc_dump.xls' 
arcpy.Delete_management("tmp_view")&lt;/PRE&gt;&lt;P&gt;If you want it to work with tables as well as feature classes, you would need to add some code to check for a shape field before adding it to flds_remove; otherwise, an error will be generated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655411#M51058</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T03:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655412#M51059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes when changing to a geodatabase and exporting it exports the area and shape fields.&lt;/P&gt;&lt;P&gt;I was using a macro but i got tired of having to open the export and run the macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 21:16:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655412#M51059</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2016-05-03T21:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655413#M51060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 21:31:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655413#M51060</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2016-05-03T21:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column before exporting to excel</title>
      <link>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655414#M51061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If my or someone else's answer addressed your issue, please mark it correct so others know it has been answered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2016 16:43:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-column-before-exporting-to-excel/m-p/655414#M51061</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-05-04T16:43:16Z</dc:date>
    </item>
  </channel>
</rss>

