LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match two columns in a txt file randomly

Solved!
Go to solution

Hi Guys!

 

I have an input txt file like this (the columns are separated with tabs):

A:    B:
Kyle    Josh
Anna    Martin
Jon    Jenny

I need a VI which randomly matches pairs, one item from "A" with one item from "B". It should match all the pairs (in the example 3 pairs), and one item can be used only once. Of course I don't need the first line to be matched (the letters "A" and "B"). The number of the lines can change, and the values are not fixed.

 

I would like to kindly ask for your help.

 

 

0 Kudos
Message 1 of 6
(2,359 Views)

Hi hofferistvan,

 

- read the file using ReadFromSpreadsheetFile into an 2D array of strings.

- Delete the first row, index the first two columns.

- Feed both columns as 1D array to shift registers of a FOR loop.

- Delete a random element from both 1D arrays in the loop and output them as pair.

- Repeat the loop as long as there are elements in the array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(2,342 Views)

Thank you, but could you tell me, which functions I should use at each step you listed?

 

It would be a great help.

0 Kudos
Message 3 of 6
(2,329 Views)
Solution
Accepted by topic author hofferistvan

One other approach:

 

Read file and delete header as GerdW suggested then use the below

 

randomise.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 4 of 6
(2,312 Views)

Thank you, it seems to work. But one question: how is that function called on which there is "DBL abc"?

0 Kudos
Message 5 of 6
(2,302 Views)

UnbundleCluster

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(2,293 Views)