Personal Project Portfolio
python
bash
powershell
1# This script will look for difference in two files by scanning both files against each other
2# and then outputting any missing lines to a new file.
3
4# import csv module
5import csv
6
7# instantiate both files using the open module
8# replace filenames with local files, files must be in same folder as script is run
9with open('<filename>', 'r') as f1, open('<filename2>', 'r') as f2:
10 f1_lines = f1.readlines()
11 f2_lines = f2.readlines()
12
13# use open module to iterate through lists and create output file
14# input desired filename in outputfilename area
15with open('<outputfilename>', 'w') as difference_file:
16 for line in f1_lines:
17 if line not in f2_lines:
18 difference_file.write(line)
19 for line in f2_lines:
20 if line not in f1_lines:
21 difference_file.write(line)