LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Sorting Function - Issues with array and array size

Solved!
Go to solution

Hello,

 

I am working on making a sorting function that will take in a text file with 2200+ rows x 6 columns of data, bundle by specific columns, sort by a single specific column, and then write the sorted data back to a text file in a similar 2200+ row x 6 columns text file. The issue I'm running into is the final step, writing back to a text file and having the data come out in the correct, desired format. Currently, the program will output the data as a 1 row x 6 column file, or I've gotten it to output as 1 row x 13,200+ columns.

 

Attached below is a snippet of the code I am using.

 

Thank you for your time and help!

0 Kudos
Message 1 of 7
(3,804 Views)
Solution
Accepted by topic author bengrant18

Take the ouptu of your "reverse array" and wire it to a For Loop and use a "Custer to Array" inside the For Loop. The output of that gets wired out through an indexing tunnel.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 7
(3,796 Views)

@bengrant18 wrote:

Attached below is a snippet of the code I am using.


That's not a snippet (this term has a special meaning in LabVIEW), just an image.

 


@bengrant18 wrote:

, sort by a single specific column, ...


If you just want to sort by a specific column, your code sees extremely complicated. Do you need the other columns to break ties if the dominant column has duplicates?

 

Here's one possible solution (image, not snippet :D) to simply sort by one column, disregarding the others:

 

SortByOneColumn.png

 

(to use secondary columns, just bundle more elements in the desired order in the first loop, keeping the index as last element)

0 Kudos
Message 3 of 7
(3,792 Views)

I got my problem figured out thanks to Ben's first reply. 

 

altenbach, I appreciate your advice and help. I see where you're coming from with how my code is cluttered with extra, unneeded steps. I tried your method and the output was the same string of 6 numbers over and over again, where this does not work for me. I had used the Index Bundle and Cluster Array in my first image (thanks for correcting my wording) to have each row of data connected to each other as I sort by one column (similar to that of excel's sort function where you can select data in columns A - F and sort by column F from lowest to highest number and all the data gets rearrange in according to where it's data point of column F get's moved too). 

0 Kudos
Message 4 of 7
(3,761 Views)

@bengrant18 wrote:

... tried your method and the output was the same string of 6 numbers over and over again, where this does not work for me. 


Obviously you did something wrong then. Please check the code again. It is extremely wasteful to carry gigantic data structures through the machinery if really only one column needs to be sorted.

Please attach some simple test dataset and the desired result.

 

 

0 Kudos
Message 5 of 7
(3,735 Views)
Solution
Accepted by topic author bengrant18

@altenbach wrote:

@bengrant18 wrote:

... tried your method and the output was the same string of 6 numbers over and over again, where this does not work for me. 


Obviously you did something wrong then. Please check the code again. It is extremely wasteful to carry gigantic data structures through the machinery if really only one column needs to be sorted.

Please attach some simple test dataset and the desired result. 


Here's a simple example. Obviously it does not produce the same 6 numbers over and over, but sorts by the selected column, keeping the rows intact.

 

SortByColumn.png

 

To reverse sort, reverse the sorted array before proceeding.

 

(I think there are also some openg tools to do all that, but I don't have any installed)

 

0 Kudos
Message 6 of 7
(3,731 Views)

Thank you so much altenbach! I got your version of the code working flawlessly now Smiley Happy

0 Kudos
Message 7 of 7
(3,706 Views)