Skip to main content

I have a data that contains whitespaces at the beginning, between and at the end. I have used an attributetrimmer to trim out the spaces at the beginning and end, but I am left with the spaces in between. Please, does anyone have an idea of how I can go about it because I can't keep using a stringreplacer repeatedly for this large dataset?

Does not a single StringReplacer set to replace <space> with nothing work?


No, I have tried that and it doesn't work.

 


No, I have tried that and it doesn't work.

 

I'd agree with @david_r​ here, but if you can post a sample of your data we might be able to help you further.


Kindly find attached a sample of the data I have been having the challenge in. Thank you very much @Hans van der Maarel​ and @david_r​ for your contributions so far.


@balogunopeyemi1​ Thanks for including the SpatiaLite database example. You should be able to us StringReplacer with a regular expression "\\s+" and the replacement text <space> that will remove multiple consecutive spaces.

dialog


Your data contains strings like

Rijiyar   Ganji Islamiyya Primary      School

You ask for any transformer in FME that removes whitespace in between strings all at once.

 A single StringReplacer set to replace <space> with nothing, like @david_r​ and @Hans van der Maarel​ suggest, does remove all spaces, just like you ask, and gives

RijiyarGanjiIslamiyyaPrimarySchool

But probably you want to retain one space between words. This can also be accomplished with a single String Replacer, but in 'Replace Regular Expression' mode.

Consecutive_spaces 

Text to Replace: t ]{2,}   (this means 2 or more consecutive spaces)
Replacement Text: (put a single space here)

This results in

Rijiyar Ganji Islamiyya Primary School

Your sample data contains no spaces at the beginning or at the end, but you can use an AttributeTrimmer or the Trim-function in an AttributeManager to remove those spaces.


Thanks @geomancer​ It worked perfectly well and performed what I wanted...Thanks everyone for your Contributions


Reply