Initial commit of Roster

This commit is contained in:
Media
2025-06-28 01:12:46 -05:00
commit c23d3a7676
4367 changed files with 890519 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import pdfplumber
from jinja2 import Environment, FileSystemLoader
import os
# === #1: Extract table from PDF ===
with pdfplumber.open("original.pdf") as pdf:
page = pdf.pages[0]
table = page.extract_table()
# === #2: Extract dates and initialize storage ===
headers = table[0] # ['', 'Sun 6 Jul', 'Sun 13 Jul', ...]
dates = headers[1:]
assignments = {} # {'Cleaner': ['Person 1, Person 2', ...]}
current_role = None
for row in table[1:]:
role = row[0]
people = row[1:]
if role: # Start of a new role
current_role = role
assignments[current_role] = [p if p else "" for p in people]
elif current_role:
# Additional person(s) for the current role
prev = assignments[current_role]
for i in range(len(people)):
if people[i]:
if prev[i]:
prev[i] += f", {people[i]}"
else:
prev[i] = people[i]
assignments[current_role] = prev
# === #3: Render to HTML ===
env = Environment(loader=FileSystemLoader("."))
template = env.get_template("email_template.html")
html = template.render(dates=dates, assignments=assignments)
with open("roster_output.html", "w") as f:
f.write(html)
print("✅ Full roster HTML generated.")