Sha256: 97fccbf329d6fc6ba1eb43fc67102185e9d6867d8f48dd08cc0abbd691fc1eb6

Contents?: true

Size: 391 Bytes

Versions: 4

Compression:

Stored size: 391 Bytes

Contents

#!/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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fastercsv-0.2.0 examples/csv_filter.rb
fastercsv-0.1.9 examples/csv_filter.rb
fastercsv-0.2.1 examples/csv_filter.rb
fastercsv-0.1.8 examples/csv_filter.rb