How should I organize this data?

Hi Guys,

new to RoR but I’ve been stuck on this problem for a few days now. So
is to scrape this data

  • and then organize it in the following format

    • the teams involved (top left, top right columns)
    • the match result (1,0)
    • the bans → relational to the team
    • the picks → relational to the team
      • the pick sequence
        • goes from 1-10, left picks 1st, right picks 2nd,3rd, left
          4th n 5th (pattern goes to 10)

currently using the Nokogiri gem and was able to scrape the data with
following code (saved the html and parsed it locally)

require ‘rubygems’
require ‘nokogiri’
require ‘open-uri’
require ‘csv’

f =“napb.html”)

doc = Nokogiri::XML(open(f))“file21.csv”, “wb”) do |data|
doc.css(‘table.prettytable > *’).search(‘tr’).each do |tr|
data <<‘td’).map(&:text)


I’ve been trying many different ways to put the data into arrays but I
haven’t had much success. Anyone can point me in the right direction?

Thanks a bunch

Well I am definitely not a Nokogiri expert, but I think that your first
issue may be that you are opening your HTML as XML. I think that doc =
Nokogiri::HTML(open(f)) might be better… Then I am a little worried
about your iteration structure.

doc… get the HTML … open the csv file
Then for each row as provide by data, send to file doc.css result…

Pretty sure that you want to get doc, then for each
doc.css('table.prettytable write to csv…

If I were you, I would first test my abilities to learn the content of
eg, napb.html. Then I would try writing to csv.