<?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: python script for renaming attributes in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2633#M233</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Marc, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch! It worked! I copied and pasted the code 'as it is' and it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tilottama&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Jul 2012 07:28:03 GMT</pubDate>
    <dc:creator>TilottamaGhosh</dc:creator>
    <dc:date>2012-07-02T07:28:03Z</dc:date>
    <item>
      <title>python script for renaming attributes</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2629#M229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying python scripting for the first time and couldn't achieve what I am trying to do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I have five types of Landcover - Drain, Lake, River, Water Body, and Canal. I want to name all of these 'Water'. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I figured that I could do it with this small script- !LANDCOVER!.replace("River","Water") in Field Calculator.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But, I would want to do all of them together using a python script in the 'Field Calculator'. I tried with some if, else statements, but they didn't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone please help me with this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will look forward to your response.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tilottama&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jun 2012 09:33:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2629#M229</guid>
      <dc:creator>TilottamaGhosh</dc:creator>
      <dc:date>2012-06-29T09:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: python script for renaming attributes</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2630#M230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In Field Calculator select Python parser and check Show Codeblock.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def reclass(landcover): &amp;nbsp; if landcover in ("Drain", "Lake", "River", "Water Body", "Canal"): &amp;nbsp;&amp;nbsp;&amp;nbsp; return "Water" &amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp; return landcover&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LANDCOVER = &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;reclass(!LANDCOVER!)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jun 2012 10:10:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2630#M230</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2012-06-29T10:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: python script for renaming attributes</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2631#M231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi M,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your reply. I tried with the code block you had sent. However, I was not able to make it work. I tried running the code selecting the 'type' as string. I am attaching a word document which shows the code as I ran it and the error in the Geoproessing result window. Could you please point out my mistake? Thanks again for your help. I will look forward to your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tilo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 04:39:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2631#M231</guid>
      <dc:creator>TilottamaGhosh</dc:creator>
      <dc:date>2012-07-02T04:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: python script for renaming attributes</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2632#M232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python is case sensitive - &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;Reclass &lt;/SPAN&gt;&lt;SPAN&gt;in not the same as &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;reclass&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Function is defined as &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;reclass &lt;/SPAN&gt;&lt;SPAN&gt;and &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;reclass(!LANDCOVER!)&lt;/SPAN&gt;&lt;SPAN&gt; should be used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Moreover, try to use exactly the same code in Pre-Logic area as I provided.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This code replaces every occurence of "Drain", "Lake", "River", "Water Body", "Canal" to "Water"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and other values are leaved untouched.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Beware that when you make calculations on existing field LANDCOVER, its original values cannot be reverted. (Backup copy of the data may be handy).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 07:06:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2632#M232</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2012-07-02T07:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: python script for renaming attributes</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2633#M233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Marc, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch! It worked! I copied and pasted the code 'as it is' and it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tilottama&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 07:28:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-renaming-attributes/m-p/2633#M233</guid>
      <dc:creator>TilottamaGhosh</dc:creator>
      <dc:date>2012-07-02T07:28:03Z</dc:date>
    </item>
  </channel>
</rss>

