Created
January 31, 2019 21:00
-
-
Save muneebaahmad/e9e1a7cc96456e3ae8deb65b7cf8e10b to your computer and use it in GitHub Desktop.
Checks the difference between two files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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