Sha256: 1eab0fb60c09e530db64948263ee5ec314e8b1ef3a4b281125bf4160fd402a08

Contents?: true

Size: 670 Bytes

Versions: 19

Compression:

Stored size: 670 Bytes

Contents

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

# = csv_filter.rb -- Faster CSV Reading and Writing
#
#  Created by James Edward Gray II on 2006-04-01.
#  Copyright 2006 Gray Productions. All rights reserved.

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

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/fastercsv-1.5.5/examples/csv_filter.rb
StephanZ-fastercsv-1.4.1 examples/csv_filter.rb
b2b2dot0-fastercsv-1.4.1 examples/csv_filter.rb
fastercsv-1.5.5 examples/csv_filter.rb
glennfu-faster_csv-1.5.5.1 examples/csv_filter.rb
fastercsv-1.5.4 examples/csv_filter.rb
rw_fastercsv-1.5.7 examples/csv_filter.rb
rw_fastercsv-1.5.6 examples/csv_filter.rb
fastercsv-1.5.3 examples/csv_filter.rb
fastercsv-1.5.1 examples/csv_filter.rb
fastercsv-1.1.1 examples/csv_filter.rb
fastercsv-1.0.0 examples/csv_filter.rb
fastercsv-1.2.0 examples/csv_filter.rb
fastercsv-1.1.0 examples/csv_filter.rb
fastercsv-1.4.0 examples/csv_filter.rb
fastercsv-1.2.2 examples/csv_filter.rb
fastercsv-1.2.1 examples/csv_filter.rb
fastercsv-1.2.3 examples/csv_filter.rb
fastercsv-1.5.0 examples/csv_filter.rb