Created
September 15, 2012 13:22
-
-
Save rgaudin/3727832 to your computer and use it in GitHub Desktop.
Soil Sample ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import random | |
CHARS = "abcdefghijklmnopqrstuvwxyz12345679ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
SPID_LEN = 6 | |
def generate_spid(country_code='US'): | |
''' Generate a SPID_LEN random string prefix with XX- with XX as country ''' | |
return '%s-%s' % (country_code.upper(), ''.join([random.choice(CHARS) | |
for i in range(1, SPID_LEN + 1)])) | |
def ssids_from_spid(spid): | |
''' List of 6 strings containing spid suffixed with 1-6 ''' | |
return ['%s-%d' % (spid, index) for index in range(1, 7)] | |
def generate_ssids(country_code): | |
''' Generate a list of 6 SSIDs from a country code ''' | |
return ssids_from_spid(generate_spid(country_code)) | |
if __name__ == '__main__': | |
# generate a hundred random SSIDs | |
for ssids in [' '.join(generate_ssids('ML')) for x in range(0, 100)]: | |
print(ssids) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment