public/import
directoryroo
gem to help with reading the .csv
or .xlsx
fileup_file = Roo::Spreadsheet.open("{Rails.root}/public/import/file_name.xlsx")
# set the defaul sheet
up_file.default_sheet = up_file.sheets[0]
# get the header
header = up_file.row(1)
# looping through each row in the sheet
# start at 2, since the 1st row was the header
(2..up_file.last_row).each.with_index(1) do |el, index|
row_data = Hash[[header, up_file.row(i)].transpose]
# able to access the row info
end