Knowledge Base - Technical Articles


Technical Article   HowTo:  Convert a string to proper case in the ArcMap 10 Field Calculator

Article ID: 38592
Software:  ArcGIS - ArcEditor 10 ArcGIS - ArcInfo 10 ArcGIS - ArcView 10
Platforms:  Windows XP, 2003Server, Vista, 2008Server, Win 7

Summary

The instructions provided describe how to use the ArcMap 10 Field Calculator to convert an uppercase, lower case or mixed case string to a proper case string.

For example, a string is in one of the following formats:

"hello world"
"HELLO WORLD"
"hELLO wORLD"

The Python Function .title() will convert these strings to:
"Hello World"

For information on equivalent steps in a label expression, or on performing this calculation in the ArcMap 9.3.1 or earlier Field Calculator, please see the link in the Related Information section below.

Procedure

ArcGIS Desktop 10 performs all field calculations using the Calculate Field geoprocessing tool. This expression will also work in that tool. For best results, use the Python expression option.

It is recommended that a new field be created, rather than editing and using an existing field.

  1. Add a new field to the feature class in ArcMap. -show me-

    1. Open the layer's attribute table by right-clicking the layer in the Table of Contents and selecting Open Attribute Table.
    2. In the Table window, click the Options button and select Add Field...
    3. Assign a name and set the Type drop-down to 'Text'. Make sure the field is big enough to store the values.
    4. Click OK in the Add Field dialog.
  2. Open the ArcMap Field Calculator for the field created in Step 1 by right-clicking the new field name heading in the Table View and clicking Field Calculator. Choose the Python parser option in the upper left.-show me-

    [O-Image]
  3. In the Field Calculator dialog box, type the following code in the text box under 'Your Field Name = '


    !Existing Field!.title()

  4. Click OK in the Field Calculator dialog box.

Related Information


Created: 1/5/2011
Last Modified: 5/19/2011

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

Comments

By WviGis - 08/14/2013 2:42 AM

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

It worked great for me. Unfortunately I choose 'LABEL' as a fieldname to write my result in, so I got an error '000539' that didn't make me any wiser. It took about an hour to find out that the only problem was in the fieldname! ?Is there a list of all restricted fieldnames that you can't use in Python functions? Many thanks, Bart from Belgium

Rating:

By dysonj - 03/07/2013 4:51 PM

The article is incorrect or the solution didn’t work.

I had the same experience as cartomeo describes. This code only worked when I ran the field calculator on "selected records" table view. The exact same code returned an error when viewing the "all records" table view.

Rating:

By Sage_BSB - 08/07/2012 8:09 AM

The article needs to be updated.

What about accented characters? When I use this fucntion in field calculator I obtain "Le Guã©Briand" instead of "Le Guébriand". Why english speaking people and especially programmers always forget that many languages uses accented characters? Thanks for help

Rating:

By cleotokos - 04/20/2012 9:37 AM

The article needs to be updated.

I was having the same problem as TracyCalhoun, maybe the article should read ![Existing Field]!.title() so it is clear that the exclamation marks are necessary around the field name.

Rating:

By TracyCalhoun - 01/25/2012 3:00 PM

The article is incorrect or the solution didn’t work.

I keep getting the following error message: ERROR 000539: Error running expression: "MEADOW POINTE LN".title() : EOL while scanning string literal (, line 1) Failed to execute (CalculateField). And there doesn't seem to be a work around listed in the article.

Rating:

By cartomeo - 05/20/2011 12:00 PM

Great article! It helped a lot!

This worked amazingly well, but for some reason, I could only get it to work properly when I selected the records, and ran the field calculator from the "selected records" table view vs. an "all records" table view. May be a bug, but the script still worked well once I figured this out. Anyone else experience this problem?

Rating:

By Anonymous - 05/04/2011 9:50 AM

The article needs to be updated.

With Python Parser radio button pushed, I try the form !existing_field!.title() and although it nearly completes, the .title() method required escaping or replacing '"' double-quote characters -- such as working with text: BUFORD "BUBBA" GUMP PARK

Rating:

By Anonymous - 04/22/2011 4:05 PM

I’d like to suggest some keywords to help find this article.

You should add to the instructions that the Python Parser radio buttion should be selected. Also, the code should look like !Existing Field!.title() vs. [Existing Field].title()

Rating: