LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a txt file and comparing it to another.

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

 

..

0 Kudos
Message 1 of 6
(3,156 Views)

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.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 6
(3,148 Views)

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

0 Kudos
Message 3 of 6
(3,135 Views)

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.

0 Kudos
Message 4 of 6
(3,132 Views)

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.

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 6
(3,129 Views)
0 Kudos
Message 6 of 6
(3,122 Views)