Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
2

Using roo gem to extract info for OpenStudio measure

asked 2020-09-22 08:20:59 -0500

Saif's avatar

updated 2020-09-22 11:02:14 -0500

I am trying to extract some information from excel file to use it in OpenStudio measure using roo gem. I tested the code as a standalone ruby file and it was working fine, but when I put it in OpenStudio measure I got this error message “cannot load such file -- roo”.I am not that savvy in programing so I am not sure if I am doing something wrong, also is there another way to extract information form excel file? Below a snip from the code I am trying to use

require 'roo'   

# open system input file
def Bldg.extract_bldg_hvac
    hvac_xlsx = Roo::Spreadsheet.open('./input_systems.xlsx')

Thank you,

edit retag flag offensive close merge delete

Comments

roo is not part of the list of pre-installed (well, embedded) gems that ships with the Openstudio CLI.

Julien Marrec's avatar Julien Marrec  ( 2020-09-22 09:07:44 -0500 )edit
1

thank you Julien, is there a way to include it ?

Saif's avatar Saif  ( 2020-09-22 09:27:19 -0500 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2020-09-22 10:12:03 -0500

I would suggest saving the Excel file as a comma separated value file (CSV) or tab separated value file (TSV). You can then use the CSV class that ships with ruby to extract the information.

This will work perfectly with OpenStudio and does not require a new gem (roo, which requires nokogiri, a complex gem that must be compiled for anyone to use and is incompatible with OpenStudio), thus allowing your measure to more easily be used by others.

edit flag offensive delete link more
0

answered 2020-09-22 17:30:22 -0500

updated 2020-09-22 17:44:59 -0500

If you're intent on using Excel (and Windows), you can use the win32ole class (included in the standard Ruby installation) to read and write data from a workbook.

E.g.: http://davidsulc.com/blog/2011/03/27/...

Edit: Turns out the CLI doesn't include win32ole either.

edit flag offensive delete link more

Comments

1

Are you sure? I think win32ole is excluded from the ruby provided with the OpenStudio CLI: openstudio -e "require 'win32ole'" gives an error.

shorowit's avatar shorowit  ( 2020-09-22 17:36:06 -0500 )edit

@shorowit No, I wasn't sure. Perhaps not, then. I just use it with system Ruby.

ericringold's avatar ericringold  ( 2020-09-22 17:38:38 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2020-09-22 08:20:59 -0500

Seen: 328 times

Last updated: Sep 22 '20