<?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: deleting fields from a shapefile doesn't work in my python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/deleting-fields-from-a-shapefile-doesn-t-work-in/m-p/471270#M36769</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you so much, dkwiens! you fix the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Does it work if you remove the quotes from around "field.name"? If it stays in quotes, python tries to delete a field literally called "field.Name", not the variable value.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 May 2011 21:00:58 GMT</pubDate>
    <dc:creator>YimeiWang</dc:creator>
    <dc:date>2011-05-24T21:00:58Z</dc:date>
    <item>
      <title>deleting fields from a shapefile doesn't work in my python script</title>
      <link>https://community.esri.com/t5/python-questions/deleting-fields-from-a-shapefile-doesn-t-work-in/m-p/471268#M36767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="plain" name="code"&gt;

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)

# Set a default workspace
gp.workspace = "C:\\arcgisserver\\gisdata"

# Set a default workspace
gp.toolbox = "management"

KeepList = ['FID', 'Shape', 'AREA', 'PERIMETER', 'PLACENAME', 'INCORP_FLA', 'COUNTY', 'STATE', 'SMARTLABEL', 'JURIS_NA_8', 'TAID']

fields = gp.ListFields("KY_TaxAreas.shp")


for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field.Name not in KeepList:
&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;&amp;nbsp;&amp;nbsp; gp.deletefield("KY_TaxAreas.shp", "field.Name")
&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;&amp;nbsp;&amp;nbsp; print field.Name + " is deleted"

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The whole processing seems right, and I got all print message for those fields which I want to delete. However, when I open the shapefile in ArcCatalog, those deleting fields are still there. Any idea?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 20:39:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-fields-from-a-shapefile-doesn-t-work-in/m-p/471268#M36767</guid>
      <dc:creator>YimeiWang</dc:creator>
      <dc:date>2011-05-24T20:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: deleting fields from a shapefile doesn't work in my python script</title>
      <link>https://community.esri.com/t5/python-questions/deleting-fields-from-a-shapefile-doesn-t-work-in/m-p/471269#M36768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does it work if you remove the quotes from around "field.name"? If it stays in quotes, python tries to delete a field literally called "field.Name", not the variable value.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 20:52:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-fields-from-a-shapefile-doesn-t-work-in/m-p/471269#M36768</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-05-24T20:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: deleting fields from a shapefile doesn't work in my python script</title>
      <link>https://community.esri.com/t5/python-questions/deleting-fields-from-a-shapefile-doesn-t-work-in/m-p/471270#M36769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you so much, dkwiens! you fix the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Does it work if you remove the quotes from around "field.name"? If it stays in quotes, python tries to delete a field literally called "field.Name", not the variable value.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 21:00:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-fields-from-a-shapefile-doesn-t-work-in/m-p/471270#M36769</guid>
      <dc:creator>YimeiWang</dc:creator>
      <dc:date>2011-05-24T21:00:58Z</dc:date>
    </item>
  </channel>
</rss>

