Thursday, 21 February 2019

compare two different files line by line in Python

import difflib
from difflib import HtmlDiff


with open('show_run_SW-VSS_2019-02-05.txt') as f1:
    f1_text = f1.read()
with open('show_run_SW-VSS_2019-02-01.txt') as f2:
    f2_text = f2.read()



delta_html = HtmlDiff().make_file(f1_text.splitlines(),
                                  f2_text.splitlines())

with open('diff22.html', 'w') as f:
     f.write(delta_html)

No comments:

Post a Comment

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...