#!/usr/bin/python

#This script will generate random voter data for the voters table.

import random

entries = 10000
    
table = "voters";
fields = "statevoterkey, honor, firstnam, midname, lastname, jr, party, gender, madd, mcity, mstate, mzipcode, phone, address_score, phone_score";
honors = ['', '', '', 'Mr.', 'Ms.', 'Mrs.', 'Miss', 'Dr.']
suffixes = ['', '', '', '', 'Jr.', 'III', 'Ph. D']
genders = 'MF'
parties = 'DDDDDDDDDDDDDDDIIIIIIIRGL'
vowels = 'aaaaeeeeeeeiiiooou'
consonants = 'bbccddddffggghhjkllllmnnnnnpqrrrssssssttttttvwxz'

def makeEntry(key):
    values = [str(key), 
	      random.choice(honors), 
	      randstr(3, 10), 
	      random.choice([randstr(1,1), '']),
	      randstr(5, 15),
	      random.choice(suffixes),
	      random.choice(parties),
	      random.choice(genders),
	      randnum(1,3) + ' ' + randstr(5,10) + ' St.',
              randstr(5,10),
              'NH',
              randnum(5,5),
              randphone(),
              randnum(0,5)
              randnum(0,5)]
    return "insert into %s (%s) values ('%s');" % (table, fields, 
						 "', '".join(values))

def randnum(mindigits, maxdigits):
    a = ''
    for i in range(0, random.randint(mindigits, maxdigits)):
        a = a + str(random.randint(1,9))
    return a

def randphone():
    if random.randint(0, 4) == 0:
        return ""
    else:
        return randnum(9,9)

def randstr(min, max):   
    a = ''
    for i in range(0, random.randint(min, max)):
        if i % 2:
            a = a + random.choice(consonants)
        else:
            a = a + random.choice(vowels)
    return a.capitalize()

if __name__ == '__main__':
    print "delete from %s;" % table
    for i in range(1, entries+1):
        print makeEntry(i)
