Hi everyone,
I'm quite new to this community so I apologize in advance if I make some mistake in the introduction of my question.
I have a column with building names (dromore lodge, killowen house, church of jesus etc.) and I want to use PythonCaller to capitalize each word except some of them like the articles (a, an, in, of...).
I've tried this simple code with poor results :
import fme
import fmeobjects
import re
def processFeature(feature):
str=feature.getAttribute('BUILDING_NAME')
exceptions = ['a', 'an', 'of', 'the', 'is']
for word in re.split(' ',str):
if word not in exceptions:
word = word.capitalize()
feature.setAttribute("B_NameCap", word)
pass
What I have as a result is the last word capitalize as I want (Lodge, House etc.) in the column I've created (B_NameCap).
I understand Python is giving me the last result overwriting the first one in the list.
I've tried to .append a new variable with the capitalized data and .join the data anew to no avail. I do not succeed to get around this.
I can split my data, capitalize it someway but I can't work a way to get it back as I would like (Dromore Lodge, Killowen House, Church of Jesus)
Thank you for your help.