Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Created January 28, 2014 17:58
Show Gist options
  • Save bjhaid/8672785 to your computer and use it in GitHub Desktop.
Save bjhaid/8672785 to your computer and use it in GitHub Desktop.
CSV.open('/tmp/sub.csv').each_with_object(Hash.new(0)) { |x,hash| hash[x[1]] += 1 }
@askinss
Copy link

askinss commented Jan 28, 2014

1.9.3p194 :003 > require 'csv'
=> true
1.9.3p194 :004 > CSV.open('/tmp/sub.csv').each_with_object(Hash.new(0)) { |x,hash| hash[x[1]] += 1 }
=> {"1090"=>14447, "0"=>12010, "7002"=>80, "4020"=>4831, "1040"=>65, "1010"=>66, "7010"=>2, "1050"=>2}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment