Skip to main content
Solved

random letter generator

  • March 18, 2019
  • 3 replies
  • 282 views

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

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.

3 replies

cwarren
Forum|alt.badge.img
  • 49 replies
  • 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+37
  • Contributor
  • 2002 replies
  • 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+44
  • Influencer
  • 3427 replies
  • 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