<?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: Renaming values from one field into another. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720562#M55781</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;
def Reclass(FIELD1):
&amp;nbsp; if FIELD1 == "H3010":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"
&amp;nbsp; elif FIELD1 == "ABC":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Something"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am very new to Python scripting and I am trying to write one that will take values (they are always consistent), and based on their value enter a string into another field.&amp;nbsp; I am working with data that is always coded the same (referenced below as field1, and I want to take those codes and automate a way to populate a different field based on those codes.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;I have been trying to play with this, but it hasn't worked so far:&lt;BR /&gt;&lt;BR /&gt;Expression:&lt;BR /&gt;Reclass(!FIELD1!)&lt;BR /&gt;&lt;BR /&gt;Code block:&lt;BR /&gt;def Reclass(FIELD1):&lt;BR /&gt;&amp;nbsp; if (FIELD1 == "H3010"):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"&lt;BR /&gt;&lt;BR /&gt;Ideally this is supposed to end up being an expression that the user can just load into the field calculator and it will grab the values from FIELD1 and place the desired values into FIELD2.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 06:49:49 GMT</pubDate>
    <dc:creator>ChrisPedrezuela</dc:creator>
    <dc:date>2021-12-12T06:49:49Z</dc:date>
    <item>
      <title>Renaming values from one field into another.</title>
      <link>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720561#M55780</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 very new to Python scripting and I am trying to write one that will take values (they are always consistent), and based on their value enter a string into another field.&amp;nbsp; I am working with data that is always coded the same (referenced below as field1, and I want to take those codes and automate a way to populate a different field based on those codes.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been trying to play with this, but it hasn't worked so far:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Reclass(!FIELD1!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def Reclass(FIELD1):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if (FIELD1 == "H3010"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally this is supposed to end up being an expression that the user can just load into the field calculator and it will grab the values from FIELD1 and place the desired values into FIELD2.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 18:58:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720561#M55780</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2013-10-24T18:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming values from one field into another.</title>
      <link>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720562#M55781</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;
def Reclass(FIELD1):
&amp;nbsp; if FIELD1 == "H3010":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"
&amp;nbsp; elif FIELD1 == "ABC":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Something"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am very new to Python scripting and I am trying to write one that will take values (they are always consistent), and based on their value enter a string into another field.&amp;nbsp; I am working with data that is always coded the same (referenced below as field1, and I want to take those codes and automate a way to populate a different field based on those codes.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;I have been trying to play with this, but it hasn't worked so far:&lt;BR /&gt;&lt;BR /&gt;Expression:&lt;BR /&gt;Reclass(!FIELD1!)&lt;BR /&gt;&lt;BR /&gt;Code block:&lt;BR /&gt;def Reclass(FIELD1):&lt;BR /&gt;&amp;nbsp; if (FIELD1 == "H3010"):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"&lt;BR /&gt;&lt;BR /&gt;Ideally this is supposed to end up being an expression that the user can just load into the field calculator and it will grab the values from FIELD1 and place the desired values into FIELD2.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720562#M55781</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2021-12-12T06:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming values from one field into another.</title>
      <link>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720563#M55782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, thanks for that input, Thanos.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have decided that an actual script within a toolbox is the route that I am going to go.&amp;nbsp; I have this worked out so far:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

# Set the input workspace
#
arcpy.env.workspace = arcpy.GetParameterAsText(0)

# Set the output workspace
#
outWorkspace = arcpy.GetParameterAsText(1)

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a list of the featureclasses in the input folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Validate the new feature class name for the output workspace.
&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; featureClassName = arcpy.ValidateTableName(fc, outWorkspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFeatureClass = os.path.join(outWorkspace, featureClassName)


def Reclass(symbol):
&amp;nbsp; if MTFCC == "H3010":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"
&amp;nbsp; elif MTFCC == "H1100":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Creek"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages(2))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically I am to the point where I tell it what to do and I'm not really sure how to do so.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:49:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720563#M55782</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-12T06:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming values from one field into another.</title>
      <link>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720564#M55783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi buddy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just look thru this documentation to have a feel for what you want to do, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000004m000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000004m000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Okay, thanks for that input, Thanos.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;I have decided that an actual script within a toolbox is the route that I am going to go.&amp;nbsp; I have this worked out so far:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

# Set the input workspace
#
arcpy.env.workspace = arcpy.GetParameterAsText(0)

# Set the output workspace
#
outWorkspace = arcpy.GetParameterAsText(1)

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a list of the featureclasses in the input folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Validate the new feature class name for the output workspace.
&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; featureClassName = arcpy.ValidateTableName(fc, outWorkspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFeatureClass = os.path.join(outWorkspace, featureClassName)


def Reclass(symbol):
&amp;nbsp; if MTFCC == "H3010":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"
&amp;nbsp; elif MTFCC == "H1100":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Creek"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages(2))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Basically I am to the point where I tell it what to do and I'm not really sure how to do so.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:49:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720564#M55783</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2021-12-12T06:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming values from one field into another.</title>
      <link>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720565#M55784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That was helpful.&amp;nbsp; Thanks again, Thanos!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this code is getting me closer to what I need, but I am still getting syntax errors.&amp;nbsp; Since I'm using example code blocks to copy/paste, I feel like I may be putting more into this than needed.&amp;nbsp; The user will have an open ArcMap document that will have one or two feature classes in it.&amp;nbsp; The feature classes won't always have the same name, so I would like for the input features/table to be requested, and not just signified within the code.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Secondly, do I need to have the lines that get the input and output workspace if I am running straight from the document that I am wanting the information written to?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code that I have gotten so far:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

# Set the input workspace
arcpy.env.workspace = arcpy.GetParameterAsText(0)

# Set the output workspace
outWorkspace = arcpy.GetParameterAsText(1)

try: 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a list of the featureclasses in the input folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Validate the new feature class name for the output workspace.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureClassName = arcpy.ValidateTableName(fc, outWorkspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFeatureClass = os.path.join(outWorkspace, featureClassName)
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set local variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; inTable = arcpy.GetParameterAsText(2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldName1 = "symbol"
&amp;nbsp;&amp;nbsp;&amp;nbsp; expression = "Reclass(string(!MTFCC!))"
&amp;nbsp;&amp;nbsp;&amp;nbsp; codeblock = """def Reclass(symbol):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if MTFCC == "H3010":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "River"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif MTFCC == "H1100":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Creek""""

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add fields
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(inTable, fieldName1, "STRING")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Calculate symbol values
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(inTable, fieldName1, expression, "PYTHON_9.3", codeblock)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages(2))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:49:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-values-from-one-field-into-another/m-p/720565#M55784</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-12T06:49:57Z</dc:date>
    </item>
  </channel>
</rss>

