LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview List Directory wildcard bug

When I use the "List Directory" function in labview 7.1 there appears to be a problem in the function.  The function seems sporadic in which filenames it will recognize and which it will not if the math parameter contains multiple wildcards.  In the example I provided, there are a series of files in the directory with names like  "calib_LCAL17_RAW_CH1.CSV", " calib_SCAL11_RAW_CH1.CSV" etc.  The match string I used was "calib" concatenated with "_*CAL*_RAW_CH1.CSV".  The function returns that no such files exist when there are 17 such files in the directory.

On a more positive note, when I use "data" concatenated with "_*_RAW_CH1_???.CSV" as the match parameter, and a different set of filenames including "data_5_RAW_CH1_OSL.CSV", "data_10_FORM_CH1_OSL.CSV" then it correctly finds 10 files. 

I am not sure why but i have tried many different approaches and this simply does not work.  I have a very long path and perhaps this is causing problems.

Bryan




0 Kudos
Message 1 of 17
(4,240 Views)

pattern: RESTRICTS the files and directories returned to those whose names match pattern.

This is the definition of "pattern" parameter of "List Directory" function.Smiley Wink

 

0 Kudos
Message 2 of 17
(4,229 Views)

It seems to me like "calib_*CAL*_RAW_CH1.CSV" should find "calib_LCAL17_RAW_CH1.CSV" as a match.  If you are concatenating "calib" with the rest of the string, make sure that there is no spaces before or after "calib" or the rest of the string on the concat output.  Put a probe or indicator on the concat output, and place your mouse cursor inside the indicator.  Move it all the way from left to right with the keyboard arrow keys.  You will see if there are any spaces in the string.

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 17
(4,222 Views)
Well, the problem is that in a directory where there are numerous files each containing a different numbers (as an example the file "calib_LCAL17_RAW_CH1.CSV" has the number 17 in it)--the method  returns "1"  meaning that it only found one matching file.  I checked for spaces, double underscores, etc before the first post.  The probe shows the correct  concatenation.  Still it is finding only 1 file "calib_LCAL1_RAW_CH1.CSV."  Help!  this is so annoying.
Bryan
0 Kudos
Message 4 of 17
(4,210 Views)
So you mean by 'RESTRICT' that the files found will match the pattern but not necessarily all of them.  I am not sure I understand your post.
0 Kudos
Message 5 of 17
(4,211 Views)
For as long as I can remember (since MS-DOS 3.0, anyway) the "*" wildcard can only be used at THE END of a filename (or the end of an extension).
It stands for "any number(including zero) of characters following this is to be considered a match". There can never be an asterisk in the middle of a filename.

Given these two names:




calib_LCAL17_RAW_CH1.CSV
calib_SCAL11_RAW_CH1.CSV


, you could have a mask like


calib_?CAL??_RAW_CH?.CSV

which would find them both.


Unlike "*", the "?" spec refers to one and only one character position. Thus you can use more than one "?".

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 17
(4,206 Views)
Sorry CoastalMaineBird, that is not true.  The * wild card can be used anywhere in a filename, and matches any number of characters, including 0 characters.  As a test, I just put a list of text files in my temp directory:
cal_test_cal.txt
cal_1test_cal.txt
cal_1test1_cal.txt
cal_1test123_cal.txt
cal_123test123_cal.txt
Then I wrote a simple vi with List Files, provided the temp directory and the string "cal_*test*_cal.txt" as inputs.  The funtion returned all 5 files.  Works here.  I have no idea why mclaugb is having a problem.  Note:  I am not using quotes in the matching string, they are shown here for clarity.
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 17
(4,196 Views)
Well, well, well. It's not the things you don't know that get you into trouble, it's the things you know for sure that ain't so...
You are correct - I am wrong, although I learned it that way a long time ago.
One possibility is that if you wire something to the DATALOG TYPE input of the LIST FILES function, it will only list files of that type. Perhaps an accidental wire has crept in.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 17
(4,183 Views)
I just looked at mclougb's vi on his first post.  He is using a subvi called List Directory+.vi.  Maybe the problem is in that subvi.  I was using the standard List Directory vi that is in Function - Files - Advanced.  Mclougb, can you please post that subvi so we can look at it?
- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 17
(4,174 Views)
I have tried it with the standard "List Directory" under advanced functions and the modified one "List Directory" that I attached before making my first post.  Neither are working.  I tried *.CSV which returned the correct number of files.  However "calib*.CSV" did not.  It only found 1 file and there are many in the folder.  Just for a test, i eliminated the concatenation and just typed in a few strings into a constant.  It is still not working.  I deleted all wires and reconnected them correctly.  The only thing I can imagine is that perhaps the path is too long.  I have that pointing to a folder which is about 7 subdirectories deep.  Perhaps the length of the search stops at a large number of characters.  HELP.  This is really holding me up!

0 Kudos
Message 10 of 17
(4,164 Views)