-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython_database_generator.py
More file actions
48 lines (42 loc) · 1020 Bytes
/
Python_database_generator.py
File metadata and controls
48 lines (42 loc) · 1020 Bytes
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
#This code is contributed by Anas Jawed
from faker import Faker
# Initialize Faker instance
fake = Faker()
# Generate HTML content
html_content = """
<!DOCTYPE html>
<html>
<head>
<title>Employee Data</title>
</head>
<body>
<h1>Employee Data</h1>
<table border="2">
<tr>
<th>Name</th>
<th>City</th>
<th>Phone Number</th>
</tr>
"""
# Generate 100 random employee records
for _ in range(100):
name = fake.name()
city = fake.city()
phone_number = fake.phone_number()
html_content += f"""
<tr>
<td>{name}</td>
<td>{city}</td>
<td>{phone_number}</td>
</tr>
"""
# Close the HTML content
html_content += """
</table>
</body>
</html>
"""
# Write the HTML content to a file
with open("employee_data.html", "w") as file:
file.write(html_content)
print("HTML file 'employee_data.html' has been generated with random employee data.")