fastercsv gem

Gem details

FasterCSV is intended as a replacement to Ruby's standard CSV library. It was designed to address concerns users of that library had and it has three primary goals:

1. Be significantly faster than CSV while remaining a pure Ruby library.
2. Use a smaller and easier to maintain code base. (FasterCSV is larger now, but considerably richer in features. The parsing core remains quite small.)
3. Improve on the CSV interface.

Author James Edward Gray Tags csv

Documentation

Install the Gem:
gem install fastercsv

Example use for a rails import

#!/usr/local/bin/ruby -w

require "faster_csv"

running_total = 0
FasterCSV.filter( :headers           => true,
                  :return_headers    => true,
                  :header_converters => :symbol,
                  :converters        => :numeric ) do |row|
  if row.header_row?
    row << "Running Total"
  else
    row << (running_total += row[:quantity] * row[:price])
  end
end


# >> Quantity,Product Description,Price,Running Total
# >> 1,Text Editor,25.0,25.0
# >> 2,MacBook Pros,2499.0,5023.0

Edit Gem | (0 older versions) | Last edited by: Guest, 3 months ago