Created
August 20, 2014 08:25
-
-
Save dleavitt/c1375737d88e2bc28194 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
CSV_SETTINGS = { | |
headers: true, # first row is headers | |
header_converters: :symbol, # convert headers to symbols | |
converters: [ | |
-> (f) { f.present? ? f : nil }, # convert empty cells to nil | |
-> (f) { f.respond_to?(:gsub) ? f.gsub(/\s+$/, '') : f }, # convert whitespace to nil | |
:all # converts things to numbers and dates | |
] | |
} | |
CSV.parse(name, CSV_SETTINGS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment