Skip to content

Commit 37a69a3

Browse files
jared-duvalclaude
andcommitted
Fix personnel costs error for budgets without trailing space in sheet name
The Summary_of_Personnel Costs sheet name varies across budget files — some have a trailing space, others do not. Look up the sheet by normalized name instead of relying on the exact string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d7c84d7 commit 37a69a3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

generate_budget_justification.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,14 @@ def __init__(self, filepath):
205205
self.domestic_travel = []
206206
self.international_travel = []
207207
self.cumulative_data = {}
208-
self.summary_sheet = self.wb['Summary_of_Personnel Costs '] # Note the trailing space
208+
# Sheet name varies: some files have a trailing space, others don't
209+
summary_name = next(
210+
(n for n in self.wb.sheetnames if n.strip() == 'Summary_of_Personnel Costs'),
211+
None
212+
)
213+
if summary_name is None:
214+
raise KeyError("Could not find 'Summary_of_Personnel Costs' sheet in workbook")
215+
self.summary_sheet = self.wb[summary_name]
209216

210217
def detect_years(self):
211218
"""Auto-detect 3, 5, or 10 year template by scanning year columns"""

0 commit comments

Comments
 (0)