It has been a while since I have done any programming in anything other than G code since I have been working as a machine shop engineer.
I need to perform a simple task, compare two text files character by character and scan for differences. The data is machine parameters from a CNC machine, since it has been having issues lately. I want to find a program that will take the two text files and compare them/output what is different if anything.
N0001 P 01001000
N0002 P 11000011
N0003 P 00000001
N0004 P 01110101
N0005 P 00110101
N0006 P 00000000
N0007 P 00000000
N0008 P 00000000
N0009 P 00010001
N0010 P 11100000
N0011 P 00000000
N0012 P 10000001
vs
N0001 P 01001000
N0002 P 11000011
N0003 P 00000001
N0004 P 01110101
N0005 P 00110101
N0006 P 00000000
N0007 P 00000000
N0008 P 00000000
N0009 P 00010001
N0010 P 11100001
N0011 P 00000000
N0012 P 10000001
there are TONS of programs that do this already, with the smarts to resync after a difference (so if file 2 has 3 lines that file 1 does not have in the middle of it, it won't say everything after the first difference is a change, it reconnects and resumes the matched parts). One of those is windiff. A fancy one that costs money is beyond compare. Commandline build into both OS exists as well, for windows its the fc command. ALL version control software like git have these tools as well.
if you want to do it yourself, do you want to resync or just hit the first difference? I don't recommend doing it yourself unless you absolutely must, but if you want to, we can certainly help.
the old one still works fine, if unofficial does not suit you.
Visual studio has the functionality built in, but its clunky to access.
notepad ++ has plugins that do it.
I have 'diff' in WSL. Previously on MSYS. Even used 'ediff' mode of GNU Emacs on Windows -- as long as diffutils were present.
Default:
$ diff first.txt second.txt
10c10
< N0010 P 11100000
---
> N0010 P 11100001
Side-by-side:
$ diff -y first.txt second.txt
N0001 P 01001000 N0001 P 01001000
N0002 P 11000011 N0002 P 11000011
N0003 P 00000001 N0003 P 00000001
N0004 P 01110101 N0004 P 01110101
N0005 P 00110101 N0005 P 00110101
N0006 P 00000000 N0006 P 00000000
N0007 P 00000000 N0007 P 00000000
N0008 P 00000000 N0008 P 00000000
N0009 P 00010001 N0009 P 00010001
N0010 P 11100000 | N0010 P 11100001
N0011 P 00000000 N0011 P 00000000
N0012 P 10000001 N0012 P 10000001
I recall a British TV series from 80's or early 90's. "Programmer" printed the two datasets ("code") on transparencies and superimposed them. Identical text was clear, changed byte was not. (Only some bytes had changed, no insertions.)
Hello. I was busy - and I could not be active on the forum. Maybe it is too late, but I would like to show you a solution that could be useful - as a first step. It works as expected, checking two vectors with all words. If you can formulate your entries differently like N0001*P*01001000, you will be able to compare each line. In my example, it compares each word (returning its index too). You can easily modify this previous code according to your project ++