CSV to Ruby Model
Add this line to your application's Gemfile:
gem 'csvmapper'
And then execute:
$ bundle
Or install it yourself as:
$ gem install csvmapper
class MyCSV < CSVMapper
column :name, 0, :integer
column :ipaddr, 1, :ipaddr
column :file_path, 2, :pathname
column :time, 3, :time
end
p MyCSV.load("name1,127.0.0.1,./tmp/path/to/file.txt,2012/01/01")
# =>
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request