Skip to content

Instantly share code, notes, and snippets.

@roktas
Created March 4, 2019 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roktas/0fdc789061ec7b2f41f74d4b1adf74c5 to your computer and use it in GitHub Desktop.
Save roktas/0fdc789061ec7b2f41f74d4b1adf74c5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'awesome_print'
require 'active_support/all'
require 'nokul-support'
require 'csv'
source_file = File.expand_path('student_list.csv', ENV['HOME'])
cache_file = source_file + '.dump'
# rubocop:disable Security/MarshalLoad
students = if File.exist? cache_file
Marshal.load File.read(cache_file)
else
CSV.read(source_file, headers: :first_row, encoding: 'bom|utf-8').tap do |array|
File.write cache_file, Marshal.dump(array)
end
end
# rubocop:enable Security/MarshalLoad
ap students.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment