Skip to content

Instantly share code, notes, and snippets.

@spacegauch0
Created November 8, 2013 15:29
Show Gist options
  • Select an option

  • Save spacegauch0/7372635 to your computer and use it in GitHub Desktop.

Select an option

Save spacegauch0/7372635 to your computer and use it in GitHub Desktop.
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