Python Forum
Diff between 1 file to serveral files - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Diff between 1 file to serveral files (/thread-4452.html)



Diff between 1 file to serveral files - tcpip - Aug-17-2017

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()



RE: Diff between 1 file to serveral files - nilamo - Aug-17-2017

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/HEAD/tree/trunk/src/usr/bin/diffuse


RE: Diff between 1 file to serveral files - tcpip - Aug-18-2017

thanks for the info.


RE: Diff between 1 file to serveral files - tcpip - Aug-21-2017

I checked the link but still dont know how to make a compare from many to one.

thanks.