summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2010-05-21 15:51:06 +0200
committerChristoph Helma <helma@in-silico.ch>2010-05-21 15:51:06 +0200
commitd052bf2513af6cb79380ea2644cc270db2fe0229 (patch)
tree643caa67b986d4af94bd062bc2a1882c046009f2
parent6763233ee1eab31b150bf4907ec51bd83f64a12a (diff)
parentcdc64f6c0f8ea1195a52ec566a365cd87639dd50 (diff)
Merge commit 'rautenberg/test' into development
Conflicts: application.rb
-rw-r--r--application.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/application.rb b/application.rb
index 31dc0df..0f557bf 100644
--- a/application.rb
+++ b/application.rb
@@ -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