Wednesday, December 1, 2010

From/To Replace String - Another Addition to the Batch Edit String Fields Toolbox

From/To String Replace is the latest script added to the Batch Edit String Fields Toolbox (see the Batch Edit String Fields - Free Tools for Calculating String Fields entry). A coworker needed to edit a field for labeling River polygons on a cartographic product in ArcMap. The field was a Name field but contained extra unwanted verbiage in parentheses to further explain the Name. For example:

New River (North Carolina portion)

and

Roanoke River (Lake Gaston below normal full power pool elevation 200 MSL)

She only wanted the labeling to show the river name, and not the explanation contained in parentheses. The Find and Replace script in the Batch Edit String Fields Toolbox is handy for replacing known substrings in a text field, but in this case, anything could be within the parentheses, so using the Find and Replace script wouldn’t work. [Enter the new From/To String Replace script!]

See the image of the script below. With this script, the starting character as well as the ending character of the substring you’d like to replace/remove is taken into account. The Replace With parameter is for the new string that will replace the characters to be removed. If there is nothing to replace the removed string with (like in the example above), the Replace With parameter can be left blank, and the substring will simply be removed from the field.

The From/To String Replace script can be downloaded as part of the Batch Edit String Fields Toolbox from the Geospatial Database. Feel free to provide feedback if you found this useful or if you have ideas for further enhancements.

Batch Edit String Fields Toolbox

*Note: These scripts were written in ArcGIS Desktop 9.3 and 9.3.1. They will work in ArcGIS Desktop 9.2. 9.3, 9.3.1, and 10.0 at the ArcView, ArcEditor, and ArcInfo license levels. Python 2.4, 2.5, or 2.6 is also required.

3 comments:

  1. Hi Brooke,

    I'm trying to use the Lower Case to Upper Case script but I'm having problems with selecting the input table. I don't have option of adding a table, only a feature dataset. I tried adding tables in dbf format, from a file geodatabase and in excel but none worked. Any advice?

    Thanks,

    Mike

    ReplyDelete
  2. Hi Mike,

    Thanks so much for visiting my Blog and posting your question. I checked into the problem you are having. I set all of the scripts up to work with feature layer data types so that if you run the tool in ArcMap, you will have a dropdown option to select a layer from the Table of Contents rather than having to browse to the file location of the data. Now that you've posted your question, I realize that this will only work for feature classes and shapefiles, and not tables. To get the tools to work with tables, here's what you can do:

    Once you've added the BatchEditStringFields.tbx to ArcToolbox (in either ArcMap or ArcCatalog), expand the toolbox and right click on the script you want to run with a table (in your case the Lower Case to Upper Case script). Go to Properties. Select the Parameters tab. The first parameter for the tool is Table, and currently has a data type of Feature Layer. Click where it says Feature Layer and select Table View from the drop down menu. Then click OK to save your changes. Then you should be able to use a table with the script.

    Let me know if you have any trouble with this. I hope you can get it working.

    Brooke

    ReplyDelete
  3. Very useful article. Thank you for sharing this! Here is nice beauty shop - Marlena - palvelut Visit it sometimes.

    ReplyDelete