-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
107 lines (81 loc) · 3.1 KB
/
main.py
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from genetare_random import Name, Ind, phone, email
import openpyxl
from openpyxl.styles import Font
def main():
rn = True
keywords = []
Keywords = []
filename = input("enter the location to save the file(ex: F:/some_folder/some_name.xlsx): ")
print("keywords : name, firstname, lastname, phone, email, indname, indfirstname, "
"indlastname, indphone \n\nchoose keyword or keywords \n\nExample: name phone indname email \n")
while rn: # Checks weather the keywords exits in the list
keys = ["name", "firstname", "lastname", "phone", "email", "indname", "indfirstname", "indlastname", "indphone"]
keywords = list(input("keywords > ").lower().split())
for i in keywords:
if i not in keys:
print(f"'{i}' is not an appropriate choice.")
keywords.pop(keywords.index(i))
break
else:
rn = False
for key in keywords: # Capitalize the keys in the keywords
c = key.capitalize()
Keywords.append(c)
num = int(input("provide the length of data: ")) # stores the number to print the data
wb = openpyxl.Workbook()
ws = wb.active
ws.append(Keywords)
font = Font(color='00FF0000', italic=True, size=15) # sets the font and color and size of the first column in excel
for cell in ws["1:1"]:
cell.font = font
# set the default column width
ws.sheet_format.defaultColWidth = 20.5
def value(vals, ky): # function to write a data multiple time into the excel
rw = 2
col = 1 + keywords.index(ky)
for val in vals:
txt = ws.cell(rw, col)
if txt.value == "":
txt.value = val
else:
rw += 1
txt.value = val
for key in keywords: # write data to the excel file
if key == "name":
name = Name.fullname(num)
value(name, key)
elif key == "phone":
phn = phone(num)
value(phn, key)
elif key == "email":
Email = email(num)
value(Email, key)
elif key == "firstname":
ft_name = Name.firstname(num)
value(ft_name, key)
elif key == "lastname":
lt_name = Name.lastname(num)
value(lt_name, key)
elif key == "indphone":
in_ph = Ind.phone(num)
value(in_ph, key)
elif key == "indname":
in_name = Ind.fullname(num)
value(in_name, key)
elif key == "indfirstname":
in_fn = Ind.firstname(num)
value(in_fn, key)
elif key == "indlastname":
in_ln = Ind.lastname(num)
value(in_ln, key)
print("\nThe data has been saved to the file... Have fun")
wb.save(filename)
while True:
main()
repeat = input("Do you want to continue? Enter 'y' or 'n': ")
if repeat[0].lower() == 'y':
run = True
continue
else:
print("Thank you!")
break