Skip to content

Instantly share code, notes, and snippets.

@Rosa-Fox
Created June 7, 2017 14:04
Show Gist options
  • Save Rosa-Fox/7eebe43e41c62812ad033e8d22e43b98 to your computer and use it in GitHub Desktop.
Save Rosa-Fox/7eebe43e41c62812ad033e8d22e43b98 to your computer and use it in GitHub Desktop.
education CSV generator
require 'csv'
namespace :education do
desc "generate governance csv"
task governance: [:environment] do
# open new csv for writing
CSV.open("school-governance-results.csv", "wb") do |csv|
# iterating existing csv rows
CSV.foreach('school-governance.csv') do |row|
c = ContentItem.find_by title: row.join(',')
arr = []
arr << c.title
arr << c.base_path
arr << c.description
csv << arr
end
end
end
desc "generate SEND csv"
task send: [:environment] do
# open new csv for writing
CSV.open("send-results.csv", "wb") do |csv|
# iterating existing csv rows
CSV.foreach('send.csv') do |row|
c = ContentItem.find_by title: row.join(',')
arr = []
arr << c.title
arr << c.base_path
arr << c.description
csv << arr
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment