LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting Array searching for method

Hello guys,

I want to ask about a method to create it: 
I have this problem:


I have this files:

TTRT_1001#1_1_T10.txt

TTRT_1001#1_2_T10.txt

TTRT_1001#1_1_T200.txt

TTRT_1001#1_2_T200.txt

TTRT_1001#1_1_T35.txt

TTRT_1001#1_2_T35.txt

And I will have different numbers after T and I want to sort them by that number?

 

I uploaded my Vi. First sorting is for TTRT ( dont mind about it ) 
Thanks

0 Kudos
Message 1 of 7
(2,540 Views)

I want ot sort them in different arrays for example one array for T10 other for T35 and etc..

0 Kudos
Message 2 of 7
(2,536 Views)

When attaching an example, make sure that the control contains a list if typical filenames as default data so we don't need to tediously type something ourselves. It makes it more likely that somebody will help.

 

(You use LabVIEW 2018, so learn about the conditional tunnels. You don't need to build anything in the upper shift register if you never use the output. Of you only want the file starting with TTRT, you can enter that as a pattern for "list folder" so you won't get anything else.)

 


@Attrt wrote:

I want ot sort them in different arrays for example one array for T10 other for T35 and etc..


Do you have a small finite list of possibilities or is the number of different "T" values unknown? How should the output look like? One possibility would be a 1D array of clusters, each containing a different "T" array sorted by the key value.

 

Do you just want to group the files by T-values or should each subset also be sorted by other keys?

0 Kudos
Message 3 of 7
(2,527 Views)

Extrace decimal number from the string with offset 5 and sort by that.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 7
(2,523 Views)

Unfortunately, I don't have LV 2018 on my current machine, but I think the main activity here is the parsing of the filename and then the sorting comes into play.  You could've already figured out a good way to this in your VI, but like I said I can't open it.  I've attached my crack at the parsing and although it may not be the fastest or most elegant, it should work for all cases you encounter providing the structure of the filename doesn't change vastly.

0 Kudos
Message 5 of 7
(2,497 Views)

It's very unclear to me what your ideal output would be. 

  • Your input in the Post had 6 entries consisting of strings (file names?) separated into 4 potential "sub-strings" by underscores (_), e.g. TTRT, 1001#1, 1, and T10.txt.  Is this significant?  Is there any significance to the "#", or the ".txt"?
  • Is the desired output a rearrangement ("sorting") of this Array?  That is, do you want the same lines, but potentially in a different order?
  • Is the desired output a "selection" (a smaller Array) corresponding to some criterion (i.e. "All *_*_*_T10.txt")?  Do you want multiple selections?  Your example seems to be of the "Selection" variety, splitting the original Array into two sub-Arrays.
  • Did you understand Altenbach's suggestion about Conditional Tunnels?  Look up For Loops, learn about (output) Tunnels, learn about Indexing, and learn about the Conditional Index.  While I like Shift Registers, you don't need them if you use Conditional Tunnels (and your VI will be much "cleaner" and potentially much easier to understand).

Bob Schor

0 Kudos
Message 6 of 7
(2,474 Views)

While the specifications are not very clear, here are two potential solutions that can hopefully give you some ideas (I took some shortcuts, so modify as needed to fit your requirements):

 

  1. Top code sorts the file names by the T# numerically, ignoring the rest.
  2. Bottom code create an array of clusters, each cluster element containing the unique key part and an array of file names matching that part. (Learn about variant attributes to understand the code).

 

 

 

FakeSorting.png

0 Kudos
Message 7 of 7
(2,466 Views)