-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1042 from NREL/check-buildstock
Check a buildstock csv against an options_lookup tsv
- Loading branch information
Showing
8 changed files
with
157 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
# Load helper file and sampling file | ||
resources_dir = File.join(File.dirname(__FILE__), '../resources') | ||
require File.join(resources_dir, 'buildstock') | ||
require 'optparse' | ||
require 'csv' | ||
require_relative 'integrity_checks' | ||
|
||
options = {} | ||
OptionParser.new do |opts| | ||
opts.banner = "Usage: #{File.basename(__FILE__)} -o outfile -l lookup_file\n e.g., #{File.basename(__FILE__)} -o /path/to/buildstock.csv -l /path/to/options_lookup.tsv" | ||
|
||
opts.on('-o', '--output <STRING>', 'Output file name') do |t| | ||
options[:outfile] = t | ||
end | ||
|
||
opts.on('-l', '--lookup_file <STRING>', 'Lookup file name') do |t| | ||
options[:lookup_file] = t | ||
end | ||
|
||
opts.on_tail('-h', '--help', 'Display help') do | ||
puts opts | ||
exit! | ||
end | ||
end.parse! | ||
|
||
if (not options[:outfile]) || (not options[:lookup_file]) | ||
fail "ERROR: All 2 arguments are required. Call #{File.basename(__FILE__)} -h for usage." | ||
end | ||
|
||
outfile = options[:outfile] | ||
lookup_file = options[:lookup_file] | ||
|
||
t0 = Time.now | ||
check_buildstock(outfile, lookup_file) | ||
t1 = Time.now | ||
|
||
puts "Checking took: #{((t1 - t0) / 60.0).round(1)} minutes." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
test/tests_buildstock_csvs/buildstock_csv_bad_option/buildstock.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Building,Location,Vintage | ||
1,AL_Birmingham.Muni.AP.722280,<1940s | ||
2,AL_Huntsville.Intl.AP-Jones.Field.723230,1940s | ||
3,AL_Mobile-Rgnl.AP.722230,<1950 |
4 changes: 4 additions & 0 deletions
4
test/tests_buildstock_csvs/buildstock_csv_bad_parameter/buildstock.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Building,Location2,Vintage | ||
1,AL_Birmingham.Muni.AP.722280,<1940 | ||
2,AL_Huntsville.Intl.AP-Jones.Field.723230,1940s | ||
3,AL_Mobile-Rgnl.AP.722230,<1950 |
4 changes: 4 additions & 0 deletions
4
test/tests_buildstock_csvs/buildstock_csv_valid/buildstock.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Building,Location,Vintage | ||
1,AL_Birmingham.Muni.AP.722280,<1940 | ||
2,AL_Huntsville.Intl.AP-Jones.Field.723230,1940s | ||
3,AL_Mobile-Rgnl.AP.722230,<1950 |