Created
March 4, 2019 09:08
-
-
Save roktas/0fdc789061ec7b2f41f74d4b1adf74c5 to your computer and use it in GitHub Desktop.
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
#!/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