Guest User

Untitled

a guest
Aug 13th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. # list of requirements
  2. require 'csv'
  3. require 'mysql'
  4. require 'rubygems'
  5. require 'active_record'
  6.  
  7. ActiveRecord::Base.establish_connection(
  8. :adapter => "mysql",
  9. :host => "localhost",
  10. :username => "root",
  11. :password => "",
  12. :database => "lizreport"
  13. )
  14.  
  15. class Debt < ActiveRecord::Base
  16. #default model
  17. end
  18.  
  19. class Bill < ActiveRecord::Base
  20. #default model
  21. end
  22.  
  23. class Closure < ActiveRecord::Base
  24. #default model
  25. end
  26.  
  27.  
  28. # load up the csvs
  29. debts = 'csv/debtsowed.csv'
  30. bills = 'csv/findopen.csv'
  31. closures = 'csv/mpclosed.csv'
  32.  
  33. CSV.foreach(debts) do |row|
  34. if row[0] == "caseno" or row[1] == nil then
  35. next
  36. end
  37. history = row[3].split("-")
  38. historyc = history[2] + history[1] + history[0]
  39. data = {
  40. "caseno" => row[0],
  41. "status" => row[1],
  42. "action_code" => row[2],
  43. "history_date" => historyc.to_s,
  44. "details" => row[4],
  45. "fe" => row[5],
  46. "report_date" => Date.today
  47. }
  48. Debt.new(data).save!
  49. end
  50. row = nil
  51. data = nil
  52. CSV.foreach(bills) do |row|
  53. if row[0] == "caseno" or row[1] == nil then
  54. next
  55. end
  56. history = row[3].split("-")
  57. historyc = history[2] + history[1] + history[0]
  58. data = {
  59. "caseno" => row[0],
  60. "status" => row[1],
  61. "action_code" => row[2],
  62. "history_date" => historyc.to_s,
  63. "report_date" => Date.today
  64. }
  65. Bill.new(data).save!
  66. end
  67. row = nil
  68. data = nil
  69. CSV.foreach(closures) do |row|
  70. if row[0] == "caseno" or row[1] == nil then
  71. next
  72. end
  73. history = row[3].split("-")
  74. historyc = history[2] + history[1] + history[0]
  75. data = {
  76. "caseno" => row[0],
  77. "status" => row[1],
  78. "action_code" => row[2],
  79. "history_date" => historyc.to_s,
  80. "details" => row[4],
  81. "fe" => row[5],
  82. "report_date" => Date.today
  83. }
  84. Closure.new(data).save!
  85. end
Add Comment
Please, Sign In to add comment