Skip to content

Instantly share code, notes, and snippets.

@plusplus
Created December 17, 2013 03:03
Show Gist options
  • Save plusplus/7999310 to your computer and use it in GitHub Desktop.
Save plusplus/7999310 to your computer and use it in GitHub Desktop.
# number of rows in the file
results.size
# => 105293
# number of unique stock ids
results.map {|l| l[:stock_unique_id]}.uniq.size
# => 95067
# number of stocked lines
stocked_ids = Set.new(results.select {|l| l[:stocked] == '1'}.map {|l| l[:stock_unique_id]})
stocked_ids.size
# => 26649
# number of unstocked lines
unstocked_ids = Set.new(results.select {|l| l[:stocked] == '0'}.map {|l| l[:stock_unique_id]})
unstocked_ids.size
# => 68418
# no stock ids have both stocked and unstocked lines
stocked_ids.intersection(unstocked_ids).size
# => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment