Solved

random letter generator

  • 18 March 2019
  • 3 replies
  • 55 views

Badge +1

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

 

icon

Best answer by ebygomm 18 March 2019, 20:16

View original

3 replies

Badge

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

Badge +22

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

Userlevel 1
Badge +21

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

Reply