Large data export for multiple building IES model

The VE Python API allows users create simple programs using the Python Programming Language, to interact with a VE Model and/or Vista Results File
DanielCooke
VE Newbie
VE Newbie
Posts: 6
Joined: Wed Dec 02, 2020 12:33 pm

Re: Large data export for multiple building IES model

Post 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?
User avatar
Rhind
IES Staff
IES Staff
Posts: 87
Joined: Fri Mar 22, 2013 5:06 pm

Re: Large data export for multiple building IES model

Post 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()
Post Reply