LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview List Directory wildcard bug

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.


If "*.CSV" worked and "calib*.CSV" didn't, then:


1... My idea of an accidental wire to the DATALOG TYPE terminal is not the problem.


2... It's nothing to do with TWO asterisks in your original post.



Open a terminal window, navigate to the directory where the CSV files are, and repeat the above tests.


Try "ls *.CSV" (Mac) or "dir *.CSV" (Windows).


That should list them all.


Try "ls calib*.CSV" (Mac) or "dir calib*.CSV" (Windows).


That should list the ones starting with "calib".



If it DOESN'T, you have a problem with your names - they're not what you think they are. Copy one of the names and look for weird characters.



What OS are you on? Is it case-sensitive?

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 11 of 17
(1,221 Views)

One way to test the path too long theory is to move all the files into a temp directory under root.  Try the vi to see if it works.  If their is a path length limitation, none of us here will be able to help you.  All I can say is that the function works fine on my computer.  I wish I could tell you more.  If their is a path length limitation, please notify us all with a reply post.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 12 of 17
(1,218 Views)
I thought that you would understand quickly what I meant by RESTRICT, but I see that that I should have explained more.
 
1- you didn't provide "list directory+.vi" in your original post. so I simply replaced it with standard "list directory.vi" of LV.
 
2- you were interested in file names that were matched with you defined pattern, but "list directory.vi" eliminates those files with defined pattern. You see! it means that if there are 17 files matching your pattern and no other files in the specified path, the size of the output array will be zero. because all 17 files are matched with your pattern and consequently are eliminated from the output file names array.
 
Now we have two situations!
 
1- your "list directory+.vi" functions differently from "list directory.vi". perhaps you have built it in a way so it will return  files that match the pattern.
Result: your problem probably comes from that vi. please upload it and let us see it. I tested your program with "list directory.vi" of LV and there is no problem in distinguishing name patterns.
 
2- from the beginning you were not aware of the functionality of "list directory.vi" and thought that it will retunrn matched file names. Actually, with my first reply I supposed that you made a small mistake and misunderstood the functionality of "list directory.vi". I didn't intend to insult you at all and wanted to only mention about the point to let you find it.
 
Cheers,
Soroush
Message 13 of 17
(1,213 Views)
All,
I now understand what was referred to when by RESTRICT.  I did not understand that initially so I certainly didn't feel insulted.  I have managed to sort out the overall problem though which, as i figured, was something stupid.  I tried a shorter path as someone suggested by copying all files to another directory.  What helped me realize the problem was using "dir calib*.csv" which returned only 1 file (there are some 35 in the folder).  I then examined the filenames carefully and realized there was a space in front of every filename "calib*.csv" (except one) but not in front of "data*.csv" which is why "data*.csv" returned correctly and "calib*.csv" did not. I used some dodgy program to do a batch file rename that apparently added this space initially which I did not realize. 
Thank you so much for your help.  Without your posts, I would have probably given up and tried to do this another way.
Regards,
Bryan

0 Kudos
Message 14 of 17
(1,206 Views)

Soroush said:

2- you were interested in file names that were matched with you defined pattern, but "list directory.vi" eliminates those files with defined pattern. You see! it means that if there are 17 files matching your pattern and no other files in the specified path, the size of the output array will be zero. because all 17 files are matched with your pattern and consequently are eliminated from the output file names array.
 
--------------------------------------
 
Sorry Soroush, this is not true.  The defined pattern is not eliminated by List Directory vi.  It is just the opposite.  The output array contains files that match the pattern.  If this were not so, then the vi I used for an example would have returned all files except the ones I wanted.  My results prove that what I am saying is true.  Try it yourself.  Create a directory, C:\MyTemp, and put in some test files, like test1.txt, test2.txt, etc.  Put it some other files that won't match, like one.txt.  Then create a vi like shown below.  Use test*.txt for a match pattern.  Look at the resulting output array.  This will show that List Directory outputs files that match the pattern.
 

Message Edited by tbob on 08-17-2005 10:14 AM

- tbob

Inventor of the WORM Global
Message 15 of 17
(1,189 Views)
Yes, You're right, quite right. I couldn't accept that if I hadn't tested it by myself. actually, I've never used this function, but just take a look at detailed help of this VI in LV help docs. the followings are written in explaining the "pattern" parameter:
 
pattern: restricts the files and directories returned to those whose names match pattern. The pattern matching in this function is similar to the matching used in matching wildcards in Windows and UNIX filenames and is not like the regular expression matching performed by the Match Pattern function. If you specify characters other than the question mark character (?) or the asterisk character (*), the function displays only files or directories that contain those characters. You can use the question mark character (?) to match any single character. You can use the asterisk character (*) to match any sequence of one or more characters.
 
what do you think when you read such an explanation?Smiley Indifferent
.
.
.
.
.
.
.
.
.
.
Educating thread for me (not about LV), in expense of one star!
Message 16 of 17
(1,181 Views)
The help description is a bit misleading.  It could have been worded differently.  I only understood it because of the part about being similar to Windows and UNIX wildcards.  It should have read "restricts the output to show only the files and directories that match..."  Don't worry, I don't think anyone here would give you one star for a mistake since we all make them.
- tbob

Inventor of the WORM Global
0 Kudos
Message 17 of 17
(1,174 Views)