Select to view content in your preferred language

Changing the case of text field values

684
4
Jump to solution
06-25-2012 12:21 PM
KevinCrosby
Emerging Contributor
the arcgis help page gives the Python script of

' '.join([i.capitalize() for i in !FieldName!.split(' ')])

to change the text values of an attirbute from YAY PYTHON, yay python, YaY pYtHoN, etc to Yay Python

but when i copy and paste this into GIS and replacing FieldName with the correct field name, it give me a geoprocessing error.

any ideas on how to correctly get this to format my fields?

ArcGIS 10

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Changing_the_case_of_text_field_values...
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MarcinGasior
Frequent Contributor
This error indicates that you have something wrong in expression.
Double check if you provide existing field name (not a field alias) enclosed with ! !

() should not be a problem to run expression - just if a separate word is enclosed with (), it won't be capitalised.

View solution in original post

0 Kudos
4 Replies
MarcinGasior
Frequent Contributor
What error exactly do you get?
The code is OK so you might missed something when typing or your data is specific.

Alternatively you can try another Python function which basicaly do the same:
!FieldName!.title()
0 Kudos
KevinCrosby
Emerging Contributor
"A field name was no found or there were unbalanced quotation marks"

a couple entrys have special characters like () in them...might that be causing the issue?
0 Kudos
MarcinGasior
Frequent Contributor
This error indicates that you have something wrong in expression.
Double check if you provide existing field name (not a field alias) enclosed with ! !

() should not be a problem to run expression - just if a separate word is enclosed with (), it won't be capitalised.
0 Kudos
KevinCrosby
Emerging Contributor
Figured out the problem.  There were a couple entries with words in "" in them that seemed to ruin the script. Removed the "" surrounding the words and it started working perfectly
0 Kudos