Skip to content

Instantly share code, notes, and snippets.

@movalex
Last active August 1, 2023 10:59
Show Gist options
  • Save movalex/7ca186eddde741c8e6c5e8d6f94a9484 to your computer and use it in GitHub Desktop.
Save movalex/7ca186eddde741c8e6c5e8d6f94a9484 to your computer and use it in GitHub Desktop.
Compare two files and create file with unique lines
def find_unique(a, b):
return [item for item in b if item not in a]
a = open("file1.txt", "rb").readlines()
b = open("file2.txt", "rb").readlines()
with open("out.txt", "wb") as f:
unique_lines = find_unique(a, b)
for line in unique_lines:
f.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment