Mange a csv file more easily.
Only 3 steps to start.
"id","file name"
"1","file_01.zip"
require 'rcsv_loader'
class SampleCsv < RCsvLoader::Base
column 'id'
column 'file name', :file_name
end
sample = SampleCsv.load_file csv_file_path, encoding: 'utf-8', headers: true
rows = sample.where({ :id => "1" })
p rows.first.file_name # => "file_01.zip"
Add this line to your application's Gemfile:
gem 'rcsv_loader'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rcsv_loader
- Fork it ( https://github.com/osadake212/rcsv_loader/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request