Skip to content

Instantly share code, notes, and snippets.

@ripiuk
Created April 1, 2018 09:31
Show Gist options
  • Save ripiuk/f17457749b2f46672572aa745f5fbc15 to your computer and use it in GitHub Desktop.
Save ripiuk/f17457749b2f46672572aa745f5fbc15 to your computer and use it in GitHub Desktop.
To find the difference between two files
FIRST_FILE_PATH = 'simple_1.csv'
SECOND_FILE_PATH = 'simple_2.csv'
OUTPUT_FILE_PATH = 'file_diff.csv'
with open(FIRST_FILE_PATH, 'r') as first_file, open(SECOND_FILE_PATH, 'r') as second_file:
first_reader = first_file.readlines()
second_reader = second_file.readlines()
with open(OUTPUT_FILE_PATH, 'w+') as output:
for line in first_reader:
if line not in second_reader:
output.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment