Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DanCoughlin/28f20bb50481c21eec60f175972ea366 to your computer and use it in GitHub Desktop.
Save DanCoughlin/28f20bb50481c21eec60f175972ea366 to your computer and use it in GitHub Desktop.
Opening a CSV and parsing it out
require 'csv'
namespace :break_up_csv do
desc "take the OSP file and merge it with the active AI User accounts
to get a file (found.xls) that has OSP grant data with all user info
and another file (not_found.xls) that includes the OSP grant data that
doesn't have matching users"
task split_files: :environment do
puts "open data file."
grants = CSV.read('data/dmresults.csv', encoding: "UTF-8")
puts "Do something with first 30 rows"
puts grants[0..30]
puts "Do something with next 30 rows"
puts grants[31..60]
puts "done"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment