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