Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
require 'rubygems' require 'faster_csv' category_totals = {} FCSV.foreach('orig.csv') do |row| category_totals[row[0]] ||= 0 category_totals[row[0]] += row[1] end FCSV.open('output.csv','w') do |out| category_totals.each do |category,total| out << [category,total] end end
This paste will be private.
From the Design Piracy series on my blog: