12-12-2011 02:09 PM
Hello,
I'm trying to write a program which will read a .txt file and compare each line (row) such as:
Process1Core = 2
Process2Core = 3
Process3Core = 3
to see if its in the other txt file. Any suggestions? Do i use active X? Can someone guide me?
Help appreciated,
thannks
MrNewb
..
12-12-2011 02:31 PM
Are you trying to find whether a given line is present in the other file? Are you trying to compare all the lines in one with all of the lines in another. They are different tasks, with different outputs, either of which can be done in LabVIEW without activeX. If you can be a little more precise with what you want to do, what happens if a row is in the other file, what happens if it isn't.
12-12-2011 03:05 PM
Okay, basically it will compare the "master" txt file with a "slave" txt file. If there is a row in the master file that doesnt exist in the 'slave' it will add it to it (the location of it doesnt have to be the same).
Regards,
Peter
12-12-2011 03:09 PM - edited 12-12-2011 03:09 PM
Are these big text files? If not a simple method is to read the text files into 2 arrays of strings (use Read Text Files with "Read Lines" enabled). Then simply iterate through the master array (for-loop autoindexing) and search for the line in the other array. If not there, insert it. Then you can write out the updated array to file using Write Text File.
12-12-2011 03:11 PM
If they aren't too big you could load them both into either arrays and then pop one line at a time off out of the "master" and compare it to the lines in the slave, adding it to the slave if not found. There are other ways to do this as well.
12-12-2011 03:24 PM
This post shows you one way to do it:
http://forums.ni.com/t5/LabVIEW/compare-two-text-files/m-p/1506552#M564936