Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Difference in content of two files

Posted by ocelot (ocelot), 29 January 2007
Hi,

I am trying to write some code in TCL to find out the difference in content between two files, something similar to the unix diff command, e.g. diff file1.txt file2.txt.

I have two files like so:
file1:

1
2
3
4

file2:

1
2
3

and i want tcl to compare the two files and output the difference, i.e. 4

thanks guys

ocelot

Posted by admin (Graham Ellis), 30 January 2007
This is one of those questions that sounds so simple, but the algorithm is NOT.   I've not written any samples in Tcl that would illustrate it, but I have done quite a bit of work in PHP on the subject - when someone updates our wiki, we generate a "difference report".

There are, though, various different ways that you might want to make the comparison and I'm not sure which applies to you.  If you're comaring two text files I would give you one answer but if you are comparing two files that contain one record per line, the I'll give you another answer.  And how long are your files?  Are they small, big, or huge?    Please do give me so more information and I'll point you in the direction of the appropriate algorithms; I've "been there, done that" and am happy to help once I know which direction to go.

Posted by Lata (Lata), 15 March 2007
I too need an answer for this question. I have two files (.mdb files) I have to compare the two files and see the difference using tcl. Please advise. Thank you.

Posted by admin (Graham Ellis), 18 March 2007
Ocelet and Lata, I would be quite happy to make some further comments if you'll let me know some of the information I asked for in my previous post - otherwise I'll end up writing a complete book  

Posted by Lata (Lata), 21 March 2007
As I mentioned I have two .mdb files. I have to compare the contents of these two files. I have never known that we can compare files directly. Probably I will have to write a function and call that function to compare the files?
I do not have anything else to tell you except that they are .mdb files. Size would be approx 15 MB and yes it contains one record per line.

Posted by admin (Graham Ellis), 22 March 2007
So ... are you looking for all the lines that exist in one file but not in the other?  Many the lines in the two files be in a different order?  Is that important?  May there be a few lines missing from one file so that you can't simply compare line 1234 in the first file with line 1234 in the second?



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho