Created
June 7, 2017 14:04
-
-
Save Rosa-Fox/7eebe43e41c62812ad033e8d22e43b98 to your computer and use it in GitHub Desktop.
education CSV generator
This file contains 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
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