Skip to content

Commit fb94121

Browse files
Update extract_submissions.py
1 parent 44dc7ec commit fb94121

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

.github/scripts/extract_submissions.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
from openpyxl.styles import Alignment, Font
77
from openpyxl.utils import get_column_letter
88
from openpyxl.worksheet.datavalidation import DataValidation
9+
import pandas as pd
910

1011
# 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")
1417

1518
# Define reviewers
1619
reviewers = [f"Reviewer {i}" for i in range(1, 8)]
@@ -95,13 +98,22 @@
9598
fname = name[0]
9699
lname = name[-1] if len(name) > 1 else ""
97100

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+
98108
summary = f"""Contributions:\n{submission.get("Contributions", "").strip()}
99109
100-
Ambassador Pitch:\n{submission.get("Ambassador Pitch", "").strip()}
110+
Ambassador Pitch:\n{pitch.strip()}
111+
112+
Checkbox Summary:\n{checkboxes.strip()}
101113
102114
Extra Notes:\n{submission.get("Extra Notes", "").strip()}
103115
104-
Additional Info:\n{submission.get("Additional Info", "").strip()}"""
116+
Additional Info:\n{extra.strip()}"""
105117

106118
start = row_idx
107119
for cat, subcat, question in rubric:
@@ -110,7 +122,6 @@
110122
end = row_idx - 1
111123
candidate_ranges.append((sid, fname, lname, start, end))
112124

113-
# Merge vertical fields
114125
for col in [1, 2, 3, 4, 5]:
115126
ws.merge_cells(start_row=start, end_row=end, start_column=col, end_column=col)
116127
cell = ws.cell(row=start, column=col)
@@ -124,7 +135,7 @@
124135
max_len = max((len(str(cell.value)) if cell.value else 0) for cell in col)
125136
ws.column_dimensions[get_column_letter(col[0].column)].width = min(max_len + 5, 50)
126137

127-
# Score Summary header
138+
# Score Summary
128139
summary_ws.append(["Submission ID", "First Name", "Last Name"] + summary_categories + ["Final Score"])
129140
for col in range(1, summary_ws.max_column + 1):
130141
summary_ws.cell(row=1, column=col).font = Font(bold=True)
@@ -150,4 +161,4 @@
150161
filename = os.path.join(output_folder, f"{reviewer.replace(' ', '_').lower()}_sheet.xlsx")
151162
wb.save(filename)
152163

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

Comments
 (0)