Friday, October 30, 2009

Find and Replace for Geoprocessing

In my last post I explained how to replace values in an attribute table using the Find & Replace... tool that is available under the Options button of the attribute table. This works very nicely for replacing characters in a specified field but unfortunately does not exist as a geoprocessing tool, which means it cannot be used in Model Builder.

I have updated the Batch Edit String Fields toolbox that I blogged about in a previous entry. I have replaced the script formerly called Replace with a script called Find and Replace. This new Find and Replace script searches a field in an attribute table for user defined characters entered in the script GUI, and replaces them with characters, also entered in the script GUI. The script can be drug into Model Builder and be run as a geoprocessing tool.

The new script has been added to the Batch Edit String Fields toolbox (see Batch Edit String Fields - Free Tools for Calculating String Fields for more information on the scripts in this toolbox). You can download the toolbox from the geospatial database. Right click the link and select Save Target As... Unzip the folder and be sure to store the toolbox in the same location as all of the Python scripts – relative paths are used to locate the scripts.

Batch Edit String Fields


  1. Brooke,

    Your a rock star! Now how do I go about using something like this to do multiple Find/Replaces?

    I have 35 string values that I need to F/R individually. All of them are located in the same column. In theory I should be able to do this without having to do a long If statement, correct?

    Any help would be create.


  2. Haskett,

    Thanks for your question and for reading my blog. So you have 35 different values that you need to run the Find and Replace on within a single column. One thing you could do is right click the Find and Replace tool in ArcToolbox, and select Batch... This allows you to pre-populate the arguments for running the tool multiple times (in your case 35). This will still be time consuming to do for 35 different F/R, but any method for that many different F/R will take some time.

    Good luck with it. Let me know if you have any other questions.

    Thanks again!

  3. Brooke I try to add tolbox to my arcgis 9.3 but I can not add.Can you help me