diff options
author | mr <mr@mrautenberg.de> | 2010-05-21 14:45:10 +0200 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2010-05-21 14:45:10 +0200 |
commit | cdc64f6c0f8ea1195a52ec566a365cd87639dd50 (patch) | |
tree | 2d6b7e0e2983372c8223e710a555abbe11889181 | |
parent | fdfa5b642f47ec9cdbe8a35163fad15d45b7cb21 (diff) |
xls export encoding, xls exp headlines removed, fix export error on empty smilesstring
-rw-r--r-- | application.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/application.rb b/application.rb index c7ad2a4..04e40e5 100644 --- a/application.rb +++ b/application.rb @@ -1,5 +1,5 @@ require 'rubygems' -gem 'opentox-ruby-api-wrapper', '= 1.5.0' +gem 'opentox-ruby-api-wrapper', '= 1.5.1' require 'opentox-ruby-api-wrapper' #require 'sinatra/respond_to' #Sinatra::Application.register Sinatra::RespondTo @@ -84,20 +84,21 @@ get '/:id' do dataset.yaml when /ms-excel/ require 'spreadsheet' - response['Content-Type'] = 'application/vnd.ms-excel' + response['Content-Type'] = 'application/vnd.ms-excel' + Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet::Workbook.new tmp = Tempfile.new('opentox-feature-xls') sheet = book.create_worksheet :name => 'Training Data' - sheet.update_row(0, "Chemical Structure","Activity") sheet.column(0).width = 100 - headline = Spreadsheet::Format.new :weight => :bold, :size => 12 - 2.times{|x| sheet.row(0).set_format(x , headline)} - i = 1 + i = 0 YAML.load(dataset.yaml).data.each do |line| - smilestring = RestClient.get(line[0], :accept => 'chemical/x-daylight-smiles').to_s - line[1][0] ? val = line[1][0].first[1] ? "1" : "0" : val = "" - sheet.update_row(i, smilestring , val) - i+=1 + begin + smilestring = RestClient.get(line[0], :accept => 'chemical/x-daylight-smiles').to_s + line[1][0] ? val = line[1][0].first[1] ? "1" : "0" : val = "" + sheet.update_row(i, smilestring , val) + i+=1 + rescue + end end begin book.write tmp.path |