Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'csv'
- ############### data is as follows ###############################################################
- # 136 ,"PPLSI212 ","2004-02-20-05.06.42.000000","0001-01-01-00.00.00.000000"
- # 185 ,"PPLSI55 ","2008-04-16-05.06.42.000000","0001-01-01-00.00.00.000000"
- # 188 ,"PPLSI212 ","1993-09-07-05.06.42.000000","0001-01-01-00.00.00.000000"
- # 245 ,"PPLSI56 ","1998-06-24-05.06.42.000000","0001-01-01-00.00.00.000000"
- # 332 ,"PPLSI242.DOP ","2009-09-21-14.33.26.000000","2016-03-01-10.46.23.000000"
- # 332 ,"PPLSI242 ","1993-07-20-05.06.42.000000","2009-09-21-14.33.25.000000"
- # 332 ,"PPLTX242.BOP ","2016-03-01-10.46.24.000000","0001-01-01-00.00.00.000000"
- # 341 ,"PPLSI56 ","1997-08-28-05.06.42.000000","0001-01-01-00.00.00.000000"
- # 488 ,"PPLSI178.0 ","1993-08-30-05.06.42.000000","0001-01-01-00.00.00.000000"
- CSV.foreach("./CNTHST.csv", :headers => false) do |row|
- deactivated_at = row[3] == "0001-01-01-00.00.00.000000" ? nil : row[3].gsub(".", ":")
- subscription = Subscription.find_by(:billing_vendor_id => row[0].squish)
- active_at = row[2].gsub(".", ":")
- updated_at = deactivated_at.present? ? deactivated_at : active_at
- if subscription.present?
- ContractHistory.create(
- :subscription => subscription,
- :document => row[1].squish,
- :created_at => active_at,
- :updated_at => updated_at,
- :deactivated_at => deactivated_at
- )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement