Using Column headers to parse excel sheets using roo - Ruby -
can use column headers specify column number parsing excel sheet using roo
gem? current code now:
oo = openoffice.new("simple_spreadsheet.ods") oo.default_sheet = file.sheets.first (2..oo.last_row).each |line| date = oo.cell(line,'a') start_time = oo.cell(line,'b') end_time = oo.cell(line,'c') pause = oo.cell(line,'d') ... end
i parse column headers instead of specifying columns 'a' 'b' 'c' ..
. can acheive using roo
?
you can grab entire header row array , hash entire row key'd on header row.
oo = openoffice.new("simple_spreadsheet.ods") oo.default_sheet = file.sheets.first header = oo.first_row 2.upto(oo.last_row) |line| row_data = hash[header.zip oo.row[line]] ... end
you use row_data[line]
nest hashes later use.
Comments
Post a Comment