CRRA_Optimization_Tool_V2 / data /generate_resource_template.py
CarlyneB's picture
[UX] address user feedback: per-year template text and column header, more visible "Add resource" button, fixed next-tab navigation on all pages, updated method constraints intro text
20f0fcc
Raw
History Blame Contribute Delete
862 Bytes
import json
import sys
import pandas as pd
import openpyxl
from openpyxl.styles import Font
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from config.config import (resource_order, resource_unit_map, resource_groups)
wb = openpyxl.Workbook()
resource_to_unit = {
r: resource_unit_map[group]
for group, resources in resource_groups.items()
for r in resources
}
# resource_caps
ws1 = wb.active
ws1.title = "resource_caps"
ws1.append(["Resource", "Unit (per year)", "Available Amount"])
ws1["A1"].font = Font(bold=True)
ws1["B1"].font = Font(bold=True)
ws1["C1"].font = Font(bold=True)
for r in resource_order:
if "other" in r.lower():
continue
ws1.append([r, resource_to_unit.get(r, ""), float("nan")])
wb.save("data/resource_template.xlsx")
print("Template generated: data/resource_template.xlsx")