Knowledge Base - Technical Articles


Technical Article   HowTo:  Replace one value for another within a field

Article ID: 20119
Software:  ArcGIS - ArcEditor 8.3, 8.1.2, 8.2, 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 8.2, 9.0, 8.0.1, 8.0.2, 8.1.2, 8.3, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcView 8.3, 8.1.2, 8.2, 9.0, 9.1, 9.2, 9.3, 9.3.1
Platforms: N/A

Summary

Instructions provided demonstrate how to use the Replace function in the Field Calculator, to replace one value for another within a field in a table.

Procedure

  1. Load the table into ArcMap.
  2. Select Start Editing from the Editor menu.
  3. Open the table.
  4. Right-click the desired field.
  5. Select Field Calculator.
  6. Type the following in the expression box:

    replace()

  7. Place the cursor between the parenthesis of the line just typed.
  8. Select the name of the field from the Fields list.
  9. Type a comma after the end bracket surrounding the field name.
  10. Type the value to be replaced and the replacement value; enclose each value in quotation marks and separate with a comma. For example:

    replace([FLD_name],"Wisconsin","WI")

  11. Click OK.

Created: 7/27/2001
Last Modified: 5/3/2011

Article Rating: (2)
If you would like to post a comment, please login

Comments

By Anonymous - 02/16/2011 9:02 AM

The article needs to be updated.

To answer the geohaskett comment, you can mimic a multiple replace function with an If, ElseIf statement. Ex. If you want to replace values in a name field you might check the show code book, and declare and set parameters for a replacement variable, like this: replacement= "replaceText" If [name]="textToReplace1" Then replacement= "replacementText1" ElseIf [name]="textToReplace2" Then replacement= "replacementText2" Else replacement= "fail" End If name = replacement

Rating:

By Anonymous - 07/08/2010 1:49 AM

I would like to see a new article that discusses the topic outlined below.

Can you include how to do multiple Replace functions back to back?

Rating: