CSV Hasher
This is a useful utility to return arrays of hashes of a CSV input file instead of arrays of arrays supported by the CSV class of Ruby.
Installation
gem install csv_hasherUsage
require 'csv_hasher'
arr_of_hashes = CSVHasher.hashify('path/to/csv/file')By default the header column names are converted to keys of the hashes. These keys are Ruby Symbols spider cased. If you want the header values to remain as key Strings then use
arr_of_hashes = CSVHasher.hashify('path/to/csv/file', { original_col_as_keys: true })If you want your own keys then pass your keys as a parameter.
arr_of_hashes = CSVHasher.hashify('path/to/csv/file', { keys: custom_keys })Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-awesome-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-awesome-feature) - Create new Pull Request
- Relax and enjoy a beer