|
6 | 6 | from openpyxl.styles import Alignment, Font |
7 | 7 | from openpyxl.utils import get_column_letter |
8 | 8 | from openpyxl.worksheet.datavalidation import DataValidation |
| 9 | +import pandas as pd |
9 | 10 |
|
10 | 11 | # Load deduplicated submissions |
11 | | -with open("ambassador/output_step1/ambassador_submissions_deduped.csv", newline='', encoding='utf-8') as f: |
12 | | - reader = csv.DictReader(f) |
13 | | - submissions = list(reader) |
| 12 | +submissions_path = "ambassador/output_step1/ambassador_submissions_deduped.csv" |
| 13 | +contrib_path = "ambassador/contribution_details.csv" |
| 14 | + |
| 15 | +submissions = pd.read_csv(submissions_path).to_dict(orient="records") |
| 16 | +contrib_details = pd.read_csv(contrib_path).to_dict(orient="records") |
14 | 17 |
|
15 | 18 | # Define reviewers |
16 | 19 | reviewers = [f"Reviewer {i}" for i in range(1, 8)] |
|
95 | 98 | fname = name[0] |
96 | 99 | lname = name[-1] if len(name) > 1 else "" |
97 | 100 |
|
| 101 | + # Pull from contribution_details |
| 102 | + contrib_row = next((row for row in contrib_details if int(row["Submission ID"]) == int(sid)), None) |
| 103 | + pitch = contrib_row.get("How Would the Nominee Contribute as an Ambassador?", "") if contrib_row else "" |
| 104 | + extra = contrib_row.get("Any Additional Details", "") if contrib_row else "" |
| 105 | + |
| 106 | + checkboxes = "\n".join([line for line in pitch.splitlines() if "☑" in line or "✔" in line]) |
| 107 | + |
98 | 108 | summary = f"""Contributions:\n{submission.get("Contributions", "").strip()} |
99 | 109 |
|
100 | | -Ambassador Pitch:\n{submission.get("Ambassador Pitch", "").strip()} |
| 110 | +Ambassador Pitch:\n{pitch.strip()} |
| 111 | +
|
| 112 | +Checkbox Summary:\n{checkboxes.strip()} |
101 | 113 |
|
102 | 114 | Extra Notes:\n{submission.get("Extra Notes", "").strip()} |
103 | 115 |
|
104 | | -Additional Info:\n{submission.get("Additional Info", "").strip()}""" |
| 116 | +Additional Info:\n{extra.strip()}""" |
105 | 117 |
|
106 | 118 | start = row_idx |
107 | 119 | for cat, subcat, question in rubric: |
|
110 | 122 | end = row_idx - 1 |
111 | 123 | candidate_ranges.append((sid, fname, lname, start, end)) |
112 | 124 |
|
113 | | - # Merge vertical fields |
114 | 125 | for col in [1, 2, 3, 4, 5]: |
115 | 126 | ws.merge_cells(start_row=start, end_row=end, start_column=col, end_column=col) |
116 | 127 | cell = ws.cell(row=start, column=col) |
|
124 | 135 | max_len = max((len(str(cell.value)) if cell.value else 0) for cell in col) |
125 | 136 | ws.column_dimensions[get_column_letter(col[0].column)].width = min(max_len + 5, 50) |
126 | 137 |
|
127 | | - # Score Summary header |
| 138 | + # Score Summary |
128 | 139 | summary_ws.append(["Submission ID", "First Name", "Last Name"] + summary_categories + ["Final Score"]) |
129 | 140 | for col in range(1, summary_ws.max_column + 1): |
130 | 141 | summary_ws.cell(row=1, column=col).font = Font(bold=True) |
|
150 | 161 | filename = os.path.join(output_folder, f"{reviewer.replace(' ', '_').lower()}_sheet.xlsx") |
151 | 162 | wb.save(filename) |
152 | 163 |
|
153 | | -print("✅ Reviewer sheets generated with merged reviewer comment column and updated submission summary.") |
| 164 | +print("✅ Reviewer sheets generated with enriched submission summary (including checkboxes).") |
0 commit comments