From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Organizing File List

Solved!
Go to solution

Hi all,

 

This is my problem. I am listing paths from a folder from the list path function. This filenames are uniform and start at F015-x_CHxx. However, when listing strings in alphabetical order labview messes it up obviously. 

 

What I want to do is re arrange them in the order that they are in the folder that is (F015-1-CH0 through 15). I am making a 2D array each row should be the FTE number (or the first x in the file name listed above) and I want to insert based on the channel number as the column index. However when I do this it wont work. It wants me to insert an array, which to me makes no sense at all when it clearly states new element OR sub array. what I would like to do is create a subarray of the stripped file names and then re build the paths in order. any advice helps. 

0 Kudos
Message 1 of 7
(2,683 Views)
Solution
Accepted by topic author arosss

Hi arosss,

 

If you look at the help for "Insert Into Array", you will find that the dimension can be the same as the array (n) or n-1. If you want to put a single element into a 2D array, you initialize the array with the number of elements you need, and then use "Replace Array Subset".

 

When sorting strings that represent numbers, it should work well if you use the same number of character for all numbers, padded on the left with 0's. For instance, don't use channel 5, use channel 05. Another useful tip for sorting (just about anything) that has a number associated with it, is to create a cluster where the first element is the numeric, and the second is anything. If you sort an array of these clusters, they will sort by the first element of the cluster (the numeric) and then you can later unbundle them and discard the numeric.

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

Thank you Gregory. 

I had been padding the numbers for example #1 -9 I would change to 01-09 which isn't that big of deal. However, would that still work of say I had a 0 to all the channel numbers (_CH1 would become CH01, but CH15 would become 015. Would that affect it? Also I could do that with the flight test event number (again 1 would become 01 but it goes up to 49 so that would 049 and i'm not sure how labview would process those difference in zeroes.)

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

Interesting thought about using clusters and it seems like a good idea. But since the order is actually determined by two numerics i don't think I can apply that strategy. 

0 Kudos
Message 4 of 7
(2,651 Views)
Solution
Accepted by topic author arosss

Hi arosss, when I say "pad" I mean to only put zeroes until you reach the total number of characters you want. So if you want two characters, 1 would become 01, but 15 would stay at 15. An easy way to do this is to use "format into string" with the "%02d" format. (Change the 2 if you want a different number of characters). You can make complex strings with this function. for example:

 

"ch%02d" will give you ch01 if you input a 1 or ch15 if you input a 15.

Message 5 of 7
(2,646 Views)

How to sort a (file)list on Another property:

SortByNumber.png

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

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 7
(2,525 Views)

Gregory,

 

wow that is a much simpler way of doing it than I finally figured out. Thank you for your help hope you have a solid day. 

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