Last active
August 29, 2015 13:57
-
-
Save stormxuwz/9513603 to your computer and use it in GitHub Desktop.
Check two files are the same
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
# http://stackoverflow.com/questions/19120489/compare-two-files-report-difference-in-python | |
import difflib | |
import sys | |
with open('transect_2_night_1.bin_PB_2013-09-13_151717.dat', 'r') as hosts0: | |
with open('transect_3_day_1.bin_PB_2013-09-13_150838.dat', 'r') as hosts1: | |
diff = difflib.unified_diff( | |
hosts0.readlines(), | |
hosts1.readlines(), | |
fromfile='hosts0', | |
tofile='hosts1', | |
) | |
for line in diff: | |
sys.stdout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment