3

Reporting Measure sql file manipulation

Hello Unmet,

I am currently writing a reporting measure script to output information from a models sql file. I ran into a specific road block when trying to use the execAndReturnVectorOfDouble method. I need to now loop through this vector and grab the data from the column %Grand Total, however whenever I try to use common vector methods like .length() or .size(), I get an error saying ":

Peak Sensible Load section failed and was skipped because: undefined method `size' for OpenStudio::OptionalDoubleVector:0x0001a263305ac8

Here Is a screenshot of my sql statement.

image description

Any help would be greatly appreciated!

thank you

ParticleSwarm's avatar
389
ParticleSwarm
asked 2019-01-07 08:59:02 -0500, updated 2019-01-07 09:04:22 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

2

Here is an example with similar method but with strings.

row_names = sqlFile.execAndReturnVectorOfString(rows_name_query).get
rows = []
row_names.each do |row_name|
  rows << row_name
end

rows is now a standard ruby array and you can use methods like rows.size. In my use case I then loop through rows array and perform additional tabular sql queries on each header entry for each row.

David Goldwasser's avatar
20.4k
David Goldwasser
answered 2019-01-07 12:09:59 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
2

As you indicated, your query returned an OptionalDoubleVEctor object, not a DoubleVector object. See the "OpenStudio Measures and the boost::optional Type" section in the Measure Writer's Reference Guide for background information on how to deal with these types of optional objects.

shorowit's avatar
11.8k
shorowit
answered 2019-01-07 12:46:32 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments