<?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 Delete 1st field/column in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387640#M30629</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am in the process of creating a model that will take GIS features and create all the necessary inputs needed for use in an external 3D modelling software, including legend files. What I'm struggling with is getting the legend file into an appropriate csv output with only very specific information (e.g., no extra fields, or records). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the "Additional Conversion - Generic Tools" &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=95009B25-1422-2418-7FB5-B8638ECB2FA9"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=95009B25-1422-2418-7FB5-B8638ECB2FA9&lt;/A&gt;&lt;SPAN&gt; tool I am now able to export a table to a csv. However the csv still contains an ID field (i.e., first field) which I would like to remove automatically through the geoprocessing model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there some simple python code I can use for this and if so how do I incorporate it into the model in ArcCatalog?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Jan 2012 17:05:34 GMT</pubDate>
    <dc:creator>MathieuCain</dc:creator>
    <dc:date>2012-01-23T17:05:34Z</dc:date>
    <item>
      <title>Delete 1st field/column</title>
      <link>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387640#M30629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am in the process of creating a model that will take GIS features and create all the necessary inputs needed for use in an external 3D modelling software, including legend files. What I'm struggling with is getting the legend file into an appropriate csv output with only very specific information (e.g., no extra fields, or records). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the "Additional Conversion - Generic Tools" &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=95009B25-1422-2418-7FB5-B8638ECB2FA9"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=95009B25-1422-2418-7FB5-B8638ECB2FA9&lt;/A&gt;&lt;SPAN&gt; tool I am now able to export a table to a csv. However the csv still contains an ID field (i.e., first field) which I would like to remove automatically through the geoprocessing model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there some simple python code I can use for this and if so how do I incorporate it into the model in ArcCatalog?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2012 17:05:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387640#M30629</guid>
      <dc:creator>MathieuCain</dc:creator>
      <dc:date>2012-01-23T17:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Delete 1st field/column</title>
      <link>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387641#M30630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a better tool for this in the Spatial Statistics Tools. It doesn't include any fields you do not want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005p0000003v000000.htm"&gt;Export Feature Attribute to ASCII&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2012 17:35:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387641#M30630</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-01-23T17:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Delete 1st field/column</title>
      <link>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387642#M30631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;There is a better tool for this in the Spatial Statistics Tools. It doesn't include any fields you do not want.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005p0000003v000000.htm"&gt;Export Feature Attribute to ASCII&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How would this work though using a table as an input rather than a feature layer?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2012 17:47:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387642#M30631</guid>
      <dc:creator>MathieuCain</dc:creator>
      <dc:date>2012-01-23T17:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delete 1st field/column</title>
      <link>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387643#M30632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, you're right, this tool (and the python script it calls, D:\ArcGIS\Desktop10.0\ArcToolbox\Scripts\ExportXYV.py), only supports feature class input.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could manipulate your output csv file using python code in a Calculate Value tool with a function embedded inside, it, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;expression: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fixfile(r"%Output file%")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;("Output File" is a model element; note the "r" and the quotes, they are important. Make "Output file" a precondition so it will exist when the Calculate Value is run.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def fixfile(infile):
&amp;nbsp; # read file into a list,&amp;nbsp;&amp;nbsp; 
&amp;nbsp; f = open(infile,"r")
&amp;nbsp; lines = readlines(f)
&amp;nbsp; f.close()
&amp;nbsp; # for each line, delete first column, write back
&amp;nbsp; f = open(infile,"w")
&amp;nbsp; for line in lines:
&amp;nbsp;&amp;nbsp;&amp;nbsp; linelist = line.split(",")
&amp;nbsp;&amp;nbsp;&amp;nbsp; lineout = ",".join(linelist[1:])
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(lineout)
&amp;nbsp; f.close()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm assuming there are no embedded commas in your data. That would break the script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:47:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-1st-field-column/m-p/387643#M30632</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T17:47:59Z</dc:date>
    </item>
  </channel>
</rss>

