I\'m trying to parse a table but I don\'t know how to save the data from it. I want to save the data in each row row to look like:
[\'Raw name 1\', 2,094, 0,017,
I assume you were borrowing some code from here or any other related references (or I am sorry for adding wrong reference) - http://quabr.com/34781600/ruby-nokogiri-parse-html-table.
However, if you want to capture all the rows, you can change the following codes -
Hope this help you to solve your problem.
doc = Nokogiri::HTML(open(html), nil, 'UTF-8')
# We need .open tr, because we want to capture all the columns from a specific table's row
@tablesArray = doc.css('table.open tr').reduce([]) do |array, row|
# This will allow us to create result as this your illustrated one
# ie. ['Raw name 1', 2,094, 0,017, 0,098, 0,113, 0,452]
array << row.css('th, td').map(&:text)
end
render template: 'scrape_krasecology'