LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing two 1D array strings

Solved!
Go to solution

Hi guys,

I am new to this community can you guys help me to how to compare two 1D array string and return the difference.

0 Kudos
Message 1 of 9
(4,032 Views)

Please define what you mean by "difference". Do both arrays have the same length? Does order matter (e.g. do you want all elements that only occur in one of the arrays). Do you only want to compare elements with the same index? etc.

 

Easiest would be to attach a simple example containing typical arrays (with default data) and the expected result.

0 Kudos
Message 2 of 9
(4,000 Views)

Thank you for your reply. I will be comparing two 1D arrays and the output will be of whats not in the first array.

 

In the VI i have tried to acess folder path which has certain files. In the first seqence i have listed the file name in the array and after that with some delay the second sequence will list the file names of the same path(few more files will be added). 

And after this the resultant array will be of whats not in the first array.

0 Kudos
Message 3 of 9
(3,990 Views)
Solution
Accepted by topic author Abraham11

I would use Sets to do the comparison.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 9
(3,975 Views)

Thank you crossrulz. You made my day

0 Kudos
Message 5 of 9
(3,967 Views)

Thanks for the files. Using "Sets" would have been my first suggestion too, but that requires at least LabVIEW 2019 and you did not mention what you have. Even without sets, the solution would have been significantly simpler than your code. 😉

 

What creates these files? Are files only added to the folder or is it also possible that some disappear after a while? You might also look for a case insensitive solution. Does the process repeat? (e.g. do you want to check for new files repeatedly?) Are the file names simple numerics and arrive in sequential numerical order? What should happen with the found difference later? Also note that if you would create these files with sufficient leading zeroes (0004.csv instead or 4.csv), an alphabetic sort would be equal to a numeric sort. (11.csv comes before 2.csv but 0002.csv comes before 0011.csv).

 

0 Kudos
Message 6 of 9
(3,945 Views)

Thanks for your reply altenbach. Is it possible do this same programming without using sets, if so can you make one for me using my code or better one so that i can learn and explore more in Labview.

 

What creates these files?

I am getting these files from third party application.

 

Are files only added to the folder or is it also possible that some disappear after a while?

The files will be keep on increasing it wouldn't disappear.

 

do you want to check for new files repeatedly?

Yes the process repeats for some numbers.

 

Are the file names simple numerics and arrive in sequential numerical order?

Yes the files will be of seqence of numbers.

 

What should happen with the found difference later?

The found difference file will be newly arrived file which is recent and i can direct the new file to further processing in Labview plotting it in a waveform graph. For sorting only i used intial code which i have posted in the begining.

 

0 Kudos
Message 7 of 9
(3,899 Views)

@Abraham11 wrote:

 

Are the file names simple numerics and arrive in sequential numerical order?

Yes the files will be of seqence of numbers.


All you need is keep a single integer in a shift register (initialized with 0 or 1, depending on how the files start out), indicating the "newest file+1" from the previous read, then, after the elapsed time, test and increment it until a corresponding file does not exist in the list.

0 Kudos
Message 8 of 9
(3,884 Views)

Please help me, compare array, i'm a new member

Ex:

array1                        array2                    ArrayResult

4.6                             4.1                          4.1

3.4                             3.4                          

4.3                             5.3                          5.3

3.5                             3.5 

4.2                             1.5                          1.5

Thanks

0 Kudos
Message 9 of 9
(3,404 Views)