LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare data from 2 text files and output match

Solved!
Go to solution

Hi all,

 

I need some advice.

 

Firstly in BinaryCode.txt the data is as such:

 

Replace BinaryCode0 1 0 0 0 0 0 0 0 0
Replace BinaryCode0 1 0 0 0 0 0 0 0 1
Replace BinaryCode1 1 1 1 0 1 1 1 1 1
Replace BinaryCode1 1 0 0 0 0 0 0 0 0

 

the first line in the text file is the header. So I need to check if the names in the second column (BinaryCode0 or BinaryCode1)appear in the Timed_Sets.txt file.

 

The data in Timed_Sets.txt is as such:

 

BinaryCode0,6,40,.........................
BinaryCode0,7,40,.........................
BCName1,0,20,.............................

BCName1,1,20,............................. 

 

For example since  BinaryCode0 is a match I will output the entire row in Timed_Set.txt to another array. 

 

I have been working on a program but I don't get the expected output. 

 

The text files and the VI are attached.

 

I appreciate your kind assistance in the matter.

 

Thank You

 

Regards

kart 

 

 

 

 

 

 

 

Download All
0 Kudos
Message 1 of 5
(3,567 Views)

Some of the code in your VI can be simplified a bit, but let's skip that for now. I don't quite understand what you're trying to do. Let's just deal with the word "BinaryCode0". You have multiple lines in BinaryCode.txt that have "BinaryCode0" in the second column. You also have multiple lines in Timed_set.txt that have "BinaryCode0" in the first column. You also said if the names in the second column (BinaryCode0 or BinaryCode1) appear in the Timed_Sets.txt file then you "will output the entire row in Timed_Set.txt" to another array. But there's more than one row in Timed_Sets.txt that has one or the other of these "keys". Your code seems to imply to output them all, but this doesn't make much sense either. Are you supposed to output them all for each instance of "BinaryCode0" in BinaryCode.txt?

 

Please clarify.

Message 2 of 5
(3,558 Views)

Hi

 

BInaryCode.txt has BinaryCode0, BinaryCode1 and BinaryCode2 and so on. Multiple entries are expected as this file is generated elsewhere. But as long as there is a single entry, the information from Timed_Sets.txt is required. So for every instance of BinaryCode0 in Timed_Sets.txt, there are information that needs to be extracted. 

 

In Timed_Sets.txt, there are multiple entries of BinaryCode0 and BCName1. I only want to move the lines with BinaryCode0 to a output array since there is a match  with the entry in BinaryCode.txt.

 

I hope this clarifies.

 

regards

kart 

 

 

 

0 Kudos
Message 3 of 5
(3,547 Views)
Solution
Accepted by topic author garfield
If I understood correctly what the output should be then what you basically need to do is to walk through the column in BinaryCode.txt and for each unique value pull out the corresponding rows from Timed_Sets.txt. There's a variety of ways to do this, depending on how much data you have and whether or not you can use any kind of prior knowledge as to the actual file content (such as the names of the keys being searched). Attached is one way. Modify as needed.
0 Kudos
Message 4 of 5
(3,498 Views)

Hi smercurio_fc

 

Thanks for your help. This is what I was looking for.

 

I will make sure to flag your reply as the solution.

 

regards

kart

0 Kudos
Message 5 of 5
(3,483 Views)