Skip to content

Instantly share code, notes, and snippets.

@muneebaahmad
Created January 31, 2019 21:00
Show Gist options
  • Save muneebaahmad/e9e1a7cc96456e3ae8deb65b7cf8e10b to your computer and use it in GitHub Desktop.
Save muneebaahmad/e9e1a7cc96456e3ae8deb65b7cf8e10b to your computer and use it in GitHub Desktop.
Checks the difference between two files
# To run, cd to this folder and put the following command in the command line
# ruby check_difference.rb
require 'set'
# Returns the user ids for emails that already exist
class Difference
FILE_ONE = 'all_emails.txt'.freeze
FILE_TWO = 'matched_emails.txt'.freeze
def check
all_emails = Set.new
matched_emails = Set.new
File.open(FILE_ONE).each do |line|
all_emails.add(line)
end
File.open(FILE_TWO).each do |line|
matched_emails.add(line)
end
diff = all_emails - matched_emails
puts diff.to_a
end
end
Difference.new.check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment