Skip to main content

Hello everyone, is there any way how to generate next letter of alphabet? E.g I have feature with value "A" and I wanna generate next letter in alphabet, so letter "B". Is there any function for that?

 

Thanks a lot!

 

Lubo

You can use the CharacterCodeExtractor to convert the letter to an integer value, increment the value with an ExpressionEvaluator, then convert it back to a letter using the CharacterCodeReplacer.

For reference, you're incrementing over the Unicode symbols, see https://symbl.cc/en/unicode/table/

The value below each symbol in hexadecimal, e.g. "A" = 41 hex = 65 decimal


You can use the CharacterCodeExtractor to convert the letter to an integer value, increment the value with an ExpressionEvaluator, then convert it back to a letter using the CharacterCodeReplacer.

For reference, you're incrementing over the Unicode symbols, see https://symbl.cc/en/unicode/table/

The value below each symbol in hexadecimal, e.g. "A" = 41 hex = 65 decimal

Nice! Learned something new today :)


Nice! Learned something new today :)

Me too, I was looking into a much more complicated solution 😄


You can use the CharacterCodeExtractor to convert the letter to an integer value, increment the value with an ExpressionEvaluator, then convert it back to a letter using the CharacterCodeReplacer.

For reference, you're incrementing over the Unicode symbols, see https://symbl.cc/en/unicode/table/

The value below each symbol in hexadecimal, e.g. "A" = 41 hex = 65 decimal

Great solution! I have known just NumToAlpha Converter (https://hub.safe.com/publishers/pacific-spatial-solutions/transformers/numtoalphaconverter), but Your solution is perfect for my usecase. Thank You so much @david_r​ !


You can use the CharacterCodeExtractor to convert the letter to an integer value, increment the value with an ExpressionEvaluator, then convert it back to a letter using the CharacterCodeReplacer.

For reference, you're incrementing over the Unicode symbols, see https://symbl.cc/en/unicode/table/

The value below each symbol in hexadecimal, e.g. "A" = 41 hex = 65 decimal

@david_r​ thats a really cool approach. I was about to ask how do you think you'd solve the wrap around when you get to 'Z' and you then want to have 'AA'. But thinking about it you could keep incrementing and use fmod() to figure out what the second char should be


@david_r​ thats a really cool approach. I was about to ask how do you think you'd solve the wrap around when you get to 'Z' and you then want to have 'AA'. But thinking about it you could keep incrementing and use fmod() to figure out what the second char should be

To be honest I'd probably do that part in Python 😉 There are some possible starting points here: https://stackoverflow.com/questions/42176498/repeating-letters-like-excel-columns

But yes, you could probably also do it in FME combining modulo and integer division, but I suspect it would be somewhat involved unless you do it in a looping custom transformer.


Reply