05-27-2020 01:45 AM
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.
Solved! Go to Solution.
05-27-2020 02:58 AM
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.
05-27-2020 03:41 AM
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.
05-27-2020 06:02 AM - edited 05-27-2020 06:02 AM
I would use Sets to do the comparison.
05-27-2020 07:04 AM
Thank you crossrulz. You made my day
05-27-2020 11:20 AM
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).
05-28-2020 04:34 AM
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.
05-28-2020 10:03 AM
@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.
01-18-2021 09:40 PM
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