<?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: Change field names with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198013#M15194</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The very worst is when, after several lengthy back-and-forths, a poster says your answer fixed their problem, and thanks you, but doesn't mark your answer correct. Then, when you gently nudge them to mark their question as answered, they mark it "assumed answered", and at the same time, ask you another question. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/angry.png" /&gt;&amp;nbsp; Sorry for the Off-topic rant PV. This wasn't about you. I thought you handled things fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Apr 2015 14:32:29 GMT</pubDate>
    <dc:creator>SepheFox</dc:creator>
    <dc:date>2015-04-28T14:32:29Z</dc:date>
    <item>
      <title>Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197993#M15174</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 have an attribute table with many fields where I have to change the field name. Most of the field names start with All_txt_ .&lt;/P&gt;&lt;P&gt;As I found out in the Data Management Forum, there is no way to automatically change all these field names in ArcGIS with a tool. Can someone tell me on how to do so with python? (I am not familiar with Python)&lt;/P&gt;&lt;P&gt;I already saw this page: &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/python/mapping-fields.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/python/mapping-fields.htm"&gt;Mapping input fields to output fields—Help | ArcGIS for Desktop&lt;/A&gt; &lt;BR /&gt;However, it does not really help me further as I don't know Python so well..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best, P.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Question is post-crossed on GIS Stack Exchange Forum&lt;BR /&gt;&lt;IMG __jive_id="88656" class="jive-image" src="https://community.esri.com/legacyfs/online/88656_delete.jpg" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 04:37:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197993#M15174</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2015-04-24T04:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197994#M15175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the &lt;STRONG&gt;alter field tool&lt;/STRONG&gt; either in a loop using a python dictionary or more simply create a bunch of one liners using something like excel to save typing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="font-size: 14.9600009918213px;"&gt;&lt;SPAN class="n" style="font-size: 14.9600009918213px;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="font-size: 14.9600009918213px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="font-size: 14.9600009918213px;"&gt;AlterField_management&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;r'C:\Data\f.gdb\foodlyr'&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;'All_txt_ws10melon'&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;'ws10melon')&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;,&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;&lt;SPAN class="n" style="font-size: 14.9600009918213px;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="font-size: 14.9600009918213px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="font-size: 14.9600009918213px;"&gt;AlterField_management&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;r'C:\Data\f.gdb\foodlyr'&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-family: monospace; font-size: 14.9600009918213px;"&gt; &lt;/SPAN&gt;&lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;'All_txt_ws10tomato'&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-family: monospace; font-size: 14.9600009918213px;"&gt; &lt;/SPAN&gt;&lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;'wstomato')&lt;/SPAN&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;and then run that by pasting it into your python command line&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;now, if you really have a lot, a python script with a loop id the better way to go. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p" style="font-size: 14.9600009918213px;"&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000198000000" title="http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000198000000"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 05:24:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197994#M15175</guid>
      <dc:creator>PeterMacKenzie</dc:creator>
      <dc:date>2015-04-24T05:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197995#M15176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;As I have many fields like this, a loop would make more sense.&lt;/P&gt;&lt;P&gt;Can you tell me how to do this? (I use ArcGIS 10.1 - as alter field management is for 10.2 onwards I am not sure if this will work)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 06:16:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197995#M15176</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2015-04-24T06:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197996#M15177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Peter, this is a run-on question from another thread. My python skills are very rudimentary, but what he needs to do is loop though his fields, and if they have All_text_ at the beginning of the name, strip it off, and make that the new field name.&lt;/P&gt;&lt;P&gt;This is my poor attempt, but I'm sure it's not quite right:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="c"&gt;#Import geoprocessing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="kn"&gt;import&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="c"&gt;#Set workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;env&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;workspace&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;r'your workspace'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s" style="font-family: courier new,courier;"&gt;fc = 'your feature class'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s"&gt;&lt;CODE&gt;&lt;SPAN class="n"&gt;fieldList&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;ListFields&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="c"&gt;#get a list of fields for each feature class&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s" style="font-family: courier new,courier;"&gt;&lt;SPAN class="c"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s"&gt;&lt;SPAN class="c"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="k"&gt;for&lt;/SPAN&gt; &lt;SPAN class="n"&gt;field&lt;/SPAN&gt; &lt;SPAN class="ow"&gt;in&lt;/SPAN&gt; &lt;SPAN class="n"&gt;fieldList&lt;/SPAN&gt;&lt;SPAN class="p"&gt;:&lt;/SPAN&gt; &lt;SPAN class="c"&gt;#loop through each field&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&amp;nbsp; fname = field.name&lt;BR /&gt;&lt;SPAN class="k"&gt;&amp;nbsp; if&lt;/SPAN&gt; fname&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;startswith&lt;SPAN class="p"&gt;("&lt;CODE style="font-size: 14.9600009918213px;"&gt;&lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;All_txt_")&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;:&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="c"&gt;#look for the stated text&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_name = fname.replace(&lt;CODE&gt;&lt;SPAN class="p"&gt;"&lt;CODE style="font-size: 14.9600009918213px;"&gt;&lt;SPAN class="s" style="font-size: 14.9600009918213px; color: #a31515;"&gt;All_txt_","") #replace with new field name&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;AlterField_management&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; field&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s"&gt;new_name&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 07:14:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197996#M15177</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-04-24T07:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197997#M15178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's another possibility, that doesn't use the Alter Fields tool. Please don't try it without making a copy of your data first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="c"&gt;#Import geoprocessing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="kn"&gt;import&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="c"&gt;#Set workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;env&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;workspace&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;r'your workspace'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s" style="font-family: courier new,courier;"&gt;fc = 'your feature class'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s"&gt;&lt;CODE&gt;&lt;SPAN class="n"&gt;fieldList&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;ListFields&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="c"&gt;#get a list of fields for each feature class&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s"&gt;&lt;SPAN class="c"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;for field in fields:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; # do not duplicate oid and geometry fields&lt;BR /&gt;&amp;nbsp; if field.Type == "OID" or field.Type == "Geometry":&lt;BR /&gt;&amp;nbsp; continue&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; # Split field name at _ symbol&lt;BR /&gt;&amp;nbsp; fieldNames = field.name.split("_")&lt;BR /&gt;&amp;nbsp; del(fieldNames[0:1])&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; # add a new field using the same properties as the original field&lt;BR /&gt;&amp;nbsp; arcpy.AddField_management(fc, fieldNames[0], field.Type)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; # calculate the values of the new field&lt;BR /&gt;&amp;nbsp; # set it to be equal to the old field&lt;BR /&gt;&amp;nbsp; arcpy.CalculateField_management(fc, fieldNames[0], field)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; # delete the old fields&lt;BR /&gt;&amp;nbsp; arcpy.DeleteField_management(fc, field)&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 07:41:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197997#M15178</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-04-24T07:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197998#M15179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wish someone would pipe up who is a python expert. I'm flailing when it comes to python, but I really want to get PV the help he needs. &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;​? &lt;A href="https://community.esri.com/migrated-users/3420"&gt;Joshua Bixby&lt;/A&gt;​?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 17:23:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197998#M15179</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-04-24T17:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197999#M15180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;​ ? &lt;A href="https://community.esri.com/migrated-users/14085"&gt;Robert Scheitlin&lt;/A&gt;​ ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, I'm of no use on this one.&amp;nbsp; I program mostly in vb.net...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 17:29:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/197999#M15180</guid>
      <dc:creator>Sol_Wuensch</dc:creator>
      <dc:date>2015-04-24T17:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198000#M15181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think I can answer your question the way a python guru could.&amp;nbsp; But maybe if you try model builder and export to python script? Using&amp;nbsp; the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000198000000"&gt;alter field &lt;/A&gt;geoprocessing tool in model builder and then exporting it as a python script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you seen this? &lt;A href="http://gis.stackexchange.com/questions/52387/renaming-field-using-arcpy" title="http://gis.stackexchange.com/questions/52387/renaming-field-using-arcpy"&gt;arcgis 10.0 - Renaming field using ArcPy? - Geographic Information Systems Stack Exchange&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 17:44:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198000#M15181</guid>
      <dc:creator>Sol_Wuensch</dc:creator>
      <dc:date>2015-04-24T17:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198001#M15182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The OP went shopping elsewhere....&lt;/P&gt;&lt;P&gt;&lt;A href="http://gis.stackexchange.com/questions/143867/change-field-names-automatically" title="http://gis.stackexchange.com/questions/143867/change-field-names-automatically"&gt;python - Change field names automatically - Geographic Information Systems Stack Exchange&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 17:45:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198001#M15182</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-04-24T17:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198002#M15183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, I have no problem with him trying several places to get an answer. Hopefully he will be kind enough to come back and let us know if he gets the answer he need though. Thanks for trying, Dan. Now I can see where I went wrong with my script, so it's good for me too!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 17:53:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198002#M15183</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-04-24T17:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198003#M15184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that the "AlterField_management" example provided by &lt;A href="https://community.esri.com/migrated-users/116103" target="_blank"&gt;Sephe Fox&lt;/A&gt; is probably the best way to go. For older versions of ArcGIS you could go with the Add Field, Calculate Field and Delete Field, but if you have access to the Alter Field tool, you can better use that one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code provided by Sephe looks OK to me, but could be written a little shorter, assuming that they are all text fields and the "ws10" can also be omitted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

fc = r'path to your feature class'
flds = arcpy.ListFields(fc, field_type="String")

for fld in flds:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fld.name.startswith("All_txt_ws10"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AlterField_management(fc, fld.name, fld.name.replace("All_txt_ws10",""), &lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;fld.name.replace("All_txt_ws10","")&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; although the help states that the input field should be of type field, it actually only works if you provide the input &lt;SPAN style="text-decoration: underline;"&gt;field name&lt;/SPAN&gt;.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll report this to Esri.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit 1: just reported to Esri&lt;/P&gt;&lt;P&gt;Edit 2: added the alias, since otherwise the old name is still shown to the user&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:53:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198003#M15184</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T09:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198004#M15185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you &lt;A href="https://community.esri.com/migrated-users/116103"&gt;Sephe Fox&lt;/A&gt;​&lt;A href="https://community.esri.com/migrated-users/3105"&gt;Sol  Wuensch&lt;/A&gt;​ &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xander's code worked perfectly on ArcGIS 10.2, however I need the code for 10.1 where I got the answer on Stackexchange (I agree with Sephe, looking for the answer at different forums should be allowed)&lt;/P&gt;&lt;P&gt;Here the link to the code which worked for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://gis.stackexchange.com/questions/143867/change-field-names-automatically" title="http://gis.stackexchange.com/questions/143867/change-field-names-automatically"&gt;python - Change field names automatically - Geographic Information Systems Stack Exchange&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got an error for Sephe's Code without the alter field management,but I am sure anyone familiar with Python could find the error very quickly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 07:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198004#M15185</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2015-04-27T07:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198005#M15186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I spotted at least one myself... it should be, for field in fieldList &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt; That's what I get for trying to think so late at night. I'm glad you solved your problem. That, after all, is the point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 07:10:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198005#M15186</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-04-27T07:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198006#M15187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/41749"&gt;P V&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you mention the version of ArcGIS for Desktop the next time you post a question. The link in your original post to the Help links to the Help of 10.3. Hence a code that works for that version.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 11:31:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198006#M15187</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-04-27T11:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198007#M15188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And giving yourself the answer after so many people contributed is bad form...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 07:18:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198007#M15188</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-04-28T07:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198008#M15189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;Yes sorry my mistake, I didn't know it was different for 10.1 until I tried Sephe's code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 07:52:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198008#M15189</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2015-04-28T07:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198009#M15190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;well technically the as correct marked answer is not my answer but the one from the link I posted. Also it is the answer which worked best on my question... But yes of course it is not very polite to do so, so I can change it to another answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 07:56:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198009#M15190</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2015-04-28T07:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198010#M15191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IMO - It's perfectly fine to cross post your question on other forums.&amp;nbsp; However, I also think it is helpful, for those trying to help with the OP, that the OP post a link to the same question on the other forum (full disclosure is appreciated by those who try to help).&amp;nbsp; Imagine taking the time to help someone and then later finding out that they had already asked their question somewhere else and were not included in that same discussion somewhere else, or if the OP gets their answer elsewhere while other people keep looking for a solution and trying to help the OP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In regard to "marking your own question as answered" I'm split on this topic.&amp;nbsp; I think the Correct answer is more coveted by those trying to help the OP.&amp;nbsp; From helping others myself, I know it can be disappointing when the OP marks their own question as the answer, especially since the correct answer is a nice form of recognition and gives the user points in the 'gamification' system.&amp;nbsp; From the perspective of someone looking for a correct answer it gets a little bit more complex - most likely future viewers of the thread don't care about points, they want to find the best possible answer to their own problem in a timely manner.&amp;nbsp; For a long thread with many responses, the user looking for a solution to their own problem will probably have to read most of the comments to fully understand and possibly find a solution to their problem.&amp;nbsp; Although, for future viewer the 'correct answer' may not be the one they are actually looking for.&amp;nbsp; Sometimes the user may find the answer somewhere else within the thread (possibly because their problem is similar but different and someone else's comment was the solution to their specific problem).&amp;nbsp; This is where the 'Helpful' tag on the comments proves it's value.&amp;nbsp; Anyone can mark a post as helpful and it awards the same number of points in the gamification system as a correct answer does.&amp;nbsp; It may be somewhere else in the thread...&amp;nbsp; It's important to realize that giving yourself the 'correct answer' does not award you any points in the gamification, but it might decrease the likelihood that the same user(s) will be willing to help you in the future.&amp;nbsp; I have felt this way before, although generally each situation is a bit different and open to interpretation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/41749"&gt;P V&lt;/A&gt;​ Maybe you can add a comment in response to the post that helped you find the solution and explain it in the thread for future users who stumble across this thread looking for a solution?&amp;nbsp; Just a few thoughts on the subject...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 13:01:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198010#M15191</guid>
      <dc:creator>Sol_Wuensch</dc:creator>
      <dc:date>2015-04-28T13:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198011#M15192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually agree 100% with you, &lt;A href="https://community.esri.com/migrated-users/3105"&gt;Sol  Wuensch&lt;/A&gt;​. Anyways, I guess I learned the lessons on how to ask a question and tag an answer on an Esri Forum now, and I appreciate all the help I got.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I will add a comment very soon!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 13:57:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198011#M15192</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2015-04-28T13:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Change field names with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198012#M15193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And now for a different perspective...&lt;/P&gt;&lt;P&gt;I am active on both sites...&lt;/P&gt;&lt;P&gt;Nothing is more irritating than to provide an answer to a post on this site than to go to the other site and find that the OP got there answer there and didn't come back here to say...sorry for the delay...got my answer there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I do appreciate, is a statement like&lt;/P&gt;&lt;P&gt;... I have cross-posted this on GIS Stack exchange as well...&lt;/P&gt;&lt;P&gt;What I will do, is see what avenues have been proposed there, so I don't waste my time trying to find an answer and post the same one here.&amp;nbsp; That is why I will post a cross-thread statement if the OP has NOT taken that courtesy since, I don't want someone to waste their time pursuing a parallel investigation and finding it has been answered elsewhere.&amp;nbsp; I will, however, investigate a question, if the other site isn't following the same train of thought I would have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in short here are some suggestions...&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;pick a site and post your question...if you don't get an answer in a reasonable period of time, post on the other site.&lt;/LI&gt;&lt;LI&gt;if you choose to post on both site because of some sense of urgency, take the effort to indicate that you have done so...I know others on both sites that won't bother to research an answer if this is not done&lt;/LI&gt;&lt;LI&gt;if you cross-post, then indicate on both sites that you have received an answer and provide the solution you accepted.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well that is my 2 cents worth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 14:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-field-names-with-python/m-p/198012#M15193</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-04-28T14:18:28Z</dc:date>
    </item>
  </channel>
</rss>

