Page 2 of 2
Re: Large data export for multiple building IES model
Posted: Fri Feb 12, 2021 10:38 am
by DanielCooke
How do i loop through the rooms in a sub group in that case, extract all the results and then add them to a variable to print as one column per group? Do you have any example code please?
Re: Large data export for multiple building IES model
Posted: Fri Feb 12, 2021 2:10 pm
by Rhind
The room group dictionary has a 'rooms' key that gives a list of room ids you can use. Here's a modified version of your script as an example:
Code: Select all
import iesve
import xlsxwriter
from ies_file_picker import IesFilePicker
workbook = xlsxwriter.Workbook('C:\\output.xlsx')
sheet1 = workbook.add_worksheet()
file_name = IesFilePicker.pick_vista_file([("APS files", "*.aps")], "Pick a results file")
with iesve.ResultsReader.open(file_name) as aps_file:
assert aps_file is not None, "Error opening results file"
rg = iesve.RoomGroups()
schemes = rg.get_grouping_schemes()
for scheme in schemes:
if scheme['name'] == 'Results':
scheme_handle = scheme['handle']
break
groups = rg.get_room_groups(scheme_handle)
# set counters to 1
col = 1
row = 1
for index, group in enumerate(groups):
sheet1.write(0, col, index)
for room_id in group['rooms']:
heat_data = aps_file.get_all_room_results(room_id, 'Room units heating load', 'z', 1, 365)
data = heat_data['Heating plant sensible load']
sheet1.write_column(row, col, data)
col += 1
workbook.close()