Python Forum

Full Version: Diff between 1 file to serveral files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have a small script I found that will compare 2 files my issue is how can I campare 1 file to many files?

Thanks.

#!/usr/bin/python
import difflib

old_path = 'Original.txt'
new_path = 'New.txt'

old_path_file = open(old_path).readlines()
new_path_file = open(new_path).readlines()

difference = difflib.HtmlDiff().make_file(old_path_file, new_path_file, old_path, new_path)
difference_report = open('./diff_report.html','w')
difference_report.write(difference)
difference_report.close()
Diffuse can compare any number of files at once: http://diffuse.sourceforge.net/index.html
It's written in python, so you can check out how they do it: https://sourceforge.net/p/diffuse/code/H...in/diffuse
thanks for the info.
I checked the link but still dont know how to make a compare from many to one.

thanks.