NREL / BuildingMOTIF

Building Metadata OnTology Interoperability Framework (BuildingMOTIF)
https://buildingmotif.readthedocs.io/
Other
48 stars 6 forks source link

Add spreadsheet generation for templates #260

Closed gtfierro closed 1 year ago

gtfierro commented 1 year ago

I needed to implement this for a demo so here's a first cut at it

from buildingmotif import BuildingMOTIF
from buildingmotif.dataclasses import Library

bm = BuildingMOTIF("sqlite://")
nrel_lib = Library.load(directory="libraries/ashrae/223p/nrel-templates")
templ = nrel_lib.get_template_by_name('sensor')

templ.generate_spreadsheet('sensor.xlsx')

Generates a spreadsheet like this:

Screenshot 2023-06-04 at 3 13 09 PM
gtfierro commented 1 year ago

I broke out tests for spreadsheet and CSV generation. It's not currently testing the write-directly-to-file path but I'd like to find a way to avoid duplicating all the test logic to handle that

gtfierro commented 1 year ago

Tests are now parameterized and a fair bit cleaner in their implementation. I should be touching all of the codepaths as well. This is ready for review!