Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # list of requirements
- require 'csv'
- require 'mysql'
- require 'rubygems'
- require 'active_record'
- ActiveRecord::Base.establish_connection(
- :adapter => "mysql",
- :host => "localhost",
- :username => "root",
- :password => "",
- :database => "lizreport"
- )
- class Debt < ActiveRecord::Base
- #default model
- end
- class Bill < ActiveRecord::Base
- #default model
- end
- class Closure < ActiveRecord::Base
- #default model
- end
- # load up the csvs
- debts = 'csv/debtsowed.csv'
- bills = 'csv/findopen.csv'
- closures = 'csv/mpclosed.csv'
- CSV.foreach(debts) do |row|
- if row[0] == "caseno" or row[1] == nil then
- next
- end
- history = row[3].split("-")
- historyc = history[2] + history[1] + history[0]
- data = {
- "caseno" => row[0],
- "status" => row[1],
- "action_code" => row[2],
- "history_date" => historyc.to_s,
- "details" => row[4],
- "fe" => row[5],
- "report_date" => Date.today
- }
- Debt.new(data).save!
- end
- row = nil
- data = nil
- CSV.foreach(bills) do |row|
- if row[0] == "caseno" or row[1] == nil then
- next
- end
- history = row[3].split("-")
- historyc = history[2] + history[1] + history[0]
- data = {
- "caseno" => row[0],
- "status" => row[1],
- "action_code" => row[2],
- "history_date" => historyc.to_s,
- "report_date" => Date.today
- }
- Bill.new(data).save!
- end
- row = nil
- data = nil
- CSV.foreach(closures) do |row|
- if row[0] == "caseno" or row[1] == nil then
- next
- end
- history = row[3].split("-")
- historyc = history[2] + history[1] + history[0]
- data = {
- "caseno" => row[0],
- "status" => row[1],
- "action_code" => row[2],
- "history_date" => historyc.to_s,
- "details" => row[4],
- "fe" => row[5],
- "report_date" => Date.today
- }
- Closure.new(data).save!
- end
Add Comment
Please, Sign In to add comment