Skip to content

Instantly share code, notes, and snippets.

@stormxuwz
Last active August 29, 2015 13:57
Show Gist options
  • Save stormxuwz/9513603 to your computer and use it in GitHub Desktop.
Save stormxuwz/9513603 to your computer and use it in GitHub Desktop.
Check two files are the same
# 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