Skip to content

Instantly share code, notes, and snippets.

@jimsynz
Created September 21, 2011 03:54
Show Gist options
  • Save jimsynz/1231205 to your computer and use it in GitHub Desktop.
Save jimsynz/1231205 to your computer and use it in GitHub Desktop.
cat tim.csv | ruby -e 'STDIN.each { |l| @h ||= {}; n,v = l.split(","); v=v.to_f; @h[n] ? @h[n] += v : @h[n] = v }; @h.each { |n,v| puts "#{n},#{v}" }'
Tim 150.00
James 15.00
Robert 200.00
James 270.13
Robert 10.00
Tim 5.00
Tim 600.00
James 13.98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment