Skip to main content
Solved

How to generate next letter of alphabet?

  • October 15, 2023
  • 6 replies
  • 60 views

lazarlubomir
Contributor
Forum|alt.badge.img+10

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

Best answer by 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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

david_r
Celebrity
  • Best Answer
  • October 16, 2023

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


nielsgerrits
VIP
Forum|alt.badge.img+62

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 :)


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • October 16, 2023

Nice! Learned something new today :)

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


lazarlubomir
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • October 16, 2023

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​ !


hkingsbury
Celebrity
Forum|alt.badge.img+65
  • Celebrity
  • October 16, 2023

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
Celebrity
  • October 17, 2023

@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.