8

Does anyone know of a way to capitalize the first letter of each word in a field in an attribute table? I am doing this in QGIS. I know of field calculations to change all the words to Lower or Upper, but I would like to be able to have the first letter Capitalized of each word, and the remaining letters lower cased. I know how to do this manually, but I am looking for an automated way. Similar to the Proper command in Excel.

Thanks...

6

Using the python field calculator:

http://hub.qgis.org/wiki/17/Using_Python_to_calculate_attribute_values_with_'fieldpyculator'

You should be able to us the .title() method on your strings:

https://stackoverflow.com/questions/3728655/python-titlecase-a-string-with-exceptions

Edit:

Assuming the attribute field you want to change is "FIELD", the sintax to use is:

value = <FIELD>.title()
  • Thank you, this seems to be on the right track, but I am a little confused with the syntax. From reading the links and others, I assumed it would be: value = str.Title( <BLD_NAME> ) but that gives a syntax error. Is there something else I need to add before str? – Ryan Garnett Apr 15 '13 at 9:01
  • 1
    Take a look into my Edit, in your especific case, it will be: value = <BLD_NAME>.title() Notice that Python is case sensitive. Also, title() is not a function but a method of the class string, that's why the syntax is string.title() – Alexandre Neto Apr 15 '13 at 10:23
7

The feature is already integrated at Qgis.

The following screen shot is from version QGis 1.9-Master, but most probably exists in previous versions as well.

enter image description here

  • I am using 1.8.0 and it is not available. – Ryan Garnett Apr 15 '13 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.