Skip to main content
Solved

random letter generator


bubblebeb
Contributor
Forum|alt.badge.img+6

I am creating some anonymized data for testing purposes and need to create a fake Land Registry Title Number (found in the UK). These are references such as CU556644 or LAN33445.

I can generate the random numbers for it but I need to generate random letters in either combination of 2 or 3 letters or both.

Has anyone come across a way of doing this?

Thanks

 

Best answer by ebygomm

You can also use a random number generator, with a min value of 97 and a max value of 122 followed by a a charactercodereplacer.

 

Or just the charactercodereplacer with @rand

View original
Did this help you find an answer to your question?

3 replies

cwarren
Forum|alt.badge.img
  • March 18, 2019

You could use python to achieve this. This function will return 2 or 3 random string characters.

import fme
import fmeobjects
import random
import string

def random_letters(feature):
    length = random.choice([2,3])
    feature.setAttribute('letters'''.join(random.choice(string.ascii_uppercase) for _ in range(length)))
    pass

random_letters.fmw


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • March 18, 2019

@madwarren's suggestion is probably the easiest way, but if you want/need to avoid python, you can use a random number generator (1-26) followed by an attributeValueMapper to map the 26 numbers to A-Z.


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • March 18, 2019

You can also use a random number generator, with a min value of 97 and a max value of 122 followed by a a charactercodereplacer.

 

Or just the charactercodereplacer with @rand


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings