Created
November 8, 2013 15:29
-
-
Save spacegauch0/7372635 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| task :give_me_the_data_bitch do | |
| data = "#{settings.root}/public/dataset.csv" | |
| puts "[#{Time.now.strftime("%H:%M:%S")}] Reading files..." | |
| CSV.foreach(data, :headers => false, :col_sep => ';') do |row| | |
| row[2] = row[2].include?(" x ") ? "TELEVISION" : row[2] | |
| row[4] = row[4].to_s.delete(",").to_f | |
| Medio.create(razon_social: row[0], periodo: row[1], medio: row[2], pauta: row[3], monto: row[4]) | |
| puts "[#{Time.now.strftime("%H:%M:%S")}] Saved record for #{row[0]}" | |
| end | |
| puts "[#{Time.now.strftime("%H:%M:%S")}] Ready, Happy Hacking!" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment