CRRA_Optimization_Tool_V2 / data /generate_resource_template.py
CarlyneB's picture
[FEAT] Goal 1 almost achieved: two types of limits possible(percentage / absolute value), start of unit conversion, adapted export templates and a bug fix in the ‘Coefficients’ tab (some resources not displayed)
64cc758
Raw
History Blame
805 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", "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:
ws1.append([r, resource_to_unit.get(r, ""), float("nan")])
wb.save("data/resource_template.xlsx")
print("Template generated: data/resource_template.xlsx")