Class: Oddb2xml::EphaExtractor
- Defined in:
- lib/oddb2xml/extractor.rb
Instance Attribute Summary
Attributes inherited from Extractor
Instance Method Summary collapse
-
#initialize(str) ⇒ EphaExtractor
constructor
A new instance of EphaExtractor.
- #to_arry ⇒ Object
Constructor Details
#initialize(str) ⇒ EphaExtractor
Returns a new instance of EphaExtractor.
368 369 370 |
# File 'lib/oddb2xml/extractor.rb', line 368 def initialize(str) @io = StringIO.new(str) end |
Instance Method Details
#to_arry ⇒ Object
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/oddb2xml/extractor.rb', line 371 def to_arry data = [] ixno = 0 inhalt = @io.read inhalt.split("\n").each do |line| ixno += 1 next if /ATC1.*Name1.*ATC2.*Name2/.match(line) #line = '"'+line unless /^"/.match(line) begin row = CSV.parse_line(line.gsub('""','"')) action = {} next unless row.size > 8 action[:ixno] = ixno action[:title] = row[4] action[:atc1] = row[0] action[:atc2] = row[2] action[:mechanism] = row[5] action[:effect] = row[6] action[:measures] = row[7] action[:grad] = row[8] data << action rescue CSV::MalformedCSVError puts "CSV::MalformedCSVError in line #{ixno}: #{line}" end end data end |