Skip to content

Instantly share code, notes, and snippets.

@kusakusakusa
Created June 18, 2015 03:31
Show Gist options
  • Save kusakusakusa/d9078fb9dc4aa994a40b to your computer and use it in GitHub Desktop.
Save kusakusakusa/d9078fb9dc4aa994a40b to your computer and use it in GitHub Desktop.
rails console
require 'csv'
file = "#{Rails.root}/data.csv"
schools = School.where(state_code: 'CO').order('name ASC')
CSV.open( file, 'w' ) do |writer|
schools.each do |s|
writer << [s.name, s.zipcode, s.id]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment