Skip to content

Instantly share code, notes, and snippets.

@jgrevich
Created June 12, 2013 20:52
Show Gist options
  • Save jgrevich/5769010 to your computer and use it in GitHub Desktop.
Save jgrevich/5769010 to your computer and use it in GitHub Desktop.
import abstract data from excel spreadsheet into bic website
require 'roo'
def find_and_update_abstract(updated_data)
abstract = Abstract.find(updated_data[0]).update_attributes(poster_number: updated_data[1], session: updated_data[2])
end
def load_and_import_data
imported_data = Roo::Excelx.new("/Users/jjg/Desktop/abstract_assignments_revised_check.xlsx")
i = 1
until imported_data.row(i).first.nil? do
i+=1
row = imported_data.row(i)
id = row[0].to_i
poster_number = row[7].to_s.include?('LCD') ? row[7] : row[7].to_i
session = row[8]
find_and_update_abstract( [id, poster_number, session] ) unless id == 44 || id == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment