lib/openstudio/analysis/translator/excel.rb in openstudio-analysis-0.3.0 vs lib/openstudio/analysis/translator/excel.rb in openstudio-analysis-0.3.1

- old
+ new

@@ -419,10 +419,13 @@ # Set the weather file as the first in the list -- this is optional new_analysis_json['analysis']['weather_file']['file_type'].downcase == 'epw' if File.extname(@weather_files.first) =~ /.zip/i new_analysis_json['analysis']['weather_file']['path'] = "./weather/#{File.basename(@weather_files.first, '.zip')}.epw" else - new_analysis_json['analysis']['weather_file']['path'] = "./weather/#{File.basename(@weather_files.first)}" + # get the first EPW file (not the first file) + weather = @weather_files.find{|w| File.extname(w).downcase == '.epw'} + fail "Could not find a weather file (*.epw) in weather directory #{File.dirname(@weather_files.first)}" unless weather + new_analysis_json['analysis']['weather_file']['path'] = "./weather/#{File.basename(weather)}" end json_file_name = "#{@export_path}/#{model[:name]}.json" FileUtils.rm_f(json_file_name) if File.exist?(json_file_name) File.open(json_file_name, 'w') { |f| f << JSON.pretty_generate(new_analysis_json) }