-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameFunction.py
More file actions
80 lines (64 loc) · 2.07 KB
/
NameFunction.py
File metadata and controls
80 lines (64 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#Realistic Name Generator by Mike Bradley
#Based on 2000 US Census and Social Security Data
import sys
import os
import csv
import random
__location__ = os.path.dirname(os.path.abspath(sys.argv[0]))
f = open(os.path.join(__location__, 'data/FemaleNames.csv'),'rU')
reader = csv.reader(f)
fNames = []
for line in reader:
fNames.append(line)
f.close()
f = open(os.path.join(__location__, 'data/MaleNames.csv'),'rU')
reader = csv.reader(f)
mNames = []
for line in reader:
mNames.append(line)
f.close()
f = open(os.path.join(__location__, 'data/LastNames.csv'),'rU')
reader = csv.reader(f)
lNames = []
for line in reader:
lNames.append(line)
f.close()
total = 0
for item in fNames:
total += int(item[1])
item[1] = total
total = 0
for item in mNames:
total += int(item[1])
item[1] = total
total = 0
for item in lNames:
total += int(item[1])
item[1] = total
def NameFunc(gender):
if gender == "M" or gender == "m":
first = random.randint(0,int(mNames[int(len(mNames))-1][1]))
last = random.randint(0,int(lNames[int(len(lNames))-1][1]))
mName = mNames[0][0]
lName = lNames[0][0]
for x in range(len(mNames)):
if int(mNames[x][1])<= first:
mName = mNames[x][0]
for x in range(len(lNames)):
if int(lNames[x][1])<= last:
lName = lNames[x][0]
return(mName+" "+lName)
elif gender == "F" or gender == "f":
first = random.randint(0,int(fNames[int(len(fNames))-1][1]))
last = random.randint(0,int(lNames[int(len(lNames))-1][1]))
fName = fNames[0][0]
lName = lNames[0][0]
for x in range(len(fNames)):
if int(fNames[x][1])<= first:
fName = fNames[x][0]
for x in range(len(lNames)):
if int(lNames[x][1])<= last:
lName = lNames[x][0]
return(fName+" "+lName)
else:
return("Invalid Gender")