Spaces:
Sleeping
Sleeping
| 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") |