LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Path with wildcards

Solved!
Go to solution

I have a directory with a data file (.txt) from each day of the month.  I want to open every file in that directory, retrieve one number and add it to a total.  The file names are a combination of the date and time and a .txt extension.  Here is an example:

 

1_2_2009 14953 PM.txt

 

I don't care what the time is, just the data.  Can I use a wild card for everything after the date in a PATH call?

 

0 Kudos
Message 1 of 12
(7,006 Views)

Hi Ronster,

you can use the "List Folder" function with a pattern like "*.txt".

 

Mike

0 Kudos
Message 2 of 12
(6,995 Views)

Mike,

Thanks.  I saw it in an older thread and was in the process of incorporating it.

Ron

 

0 Kudos
Message 3 of 12
(6,991 Views)

Mike,

It appears that the LIST vi returns an array of filenames matching the pattern.  What I want is to use the pattern to fill in the rest of the Path name after specifying a particular file, take a number out of it, add it to at total and then get the next file. 

 

for example,

The first file I want is 1_2_2009 122222 PM.txt

I want the wildcard to clear past the time, since it isn't of importance to this vi.

The next file would be 1_3_2009 84523 AM.txt

Again, I don't care about the time, just the date.

Ron

0 Kudos
Message 4 of 12
(6,982 Views)

Hi Ronster,

i don't understand it. Use the correct wildcard at the "List Folder" function and you get only the files you want. Something like "*_2009*.txt" should also be possible. The result contains all files with a name you want.

 

What do you expect as a result, if a wildcard in the path would be possible?

 

Mike

Message Edited by MikeS81 on 02-18-2009 04:49 PM
Message 5 of 12
(6,972 Views)

Mike,

Correct me if I am wrong, but the 'list' function calls for user intervention, no?  I want the user to be able to tell the vi to get all files that are in a folder for a given month and perform a given calculation based on data contained in three of the columns in all of those files.  If the list function allows me to highlite all of the files and then continue, that would work.  Not what I want, but it would give me the results needed.

I don't understand why the '*' doesn't work in my vi as a wildcard.

Ron

0 Kudos
Message 6 of 12
(6,577 Views)

 


Ronster wrote:

Correct me if I am wrong, but the 'list' function calls for user intervention, no? 


 

No!

 


Ronster wrote:

I don't understand why the '*' doesn't work in my vi as a wildcard.


 

Why don't you show us your VI?

 

0 Kudos
Message 7 of 12
(6,566 Views)

I have attached the vi as well as a sample of the files I am trying to read.  The last three columns before the time hack are the gas usage columns.  So, I set up the vi to look for the maximum value in the column.

I also attached a word doc that has the vi, the path result and the error message.  I spoke this over with my NI tech rep and he stated that the wildcard is not working properly, but it looks like it should.

Regards,

Ron

0 Kudos
Message 8 of 12
(6,556 Views)

No, this will not work.

 

First of all, you are building a filename containing a "\" which is a path delimiter and not allowed in a file name.

You cannot read a file with a wildcard in the name. A wildcard is an illegal charcter for filenames, and the resulting pattern could match, zero, one, or many files.

 

You need to build the path using year and month, then use list folder using the pattern. Then use a FOR loop and iterate over all files. A while loop is incorrect, because only the code (not the user) can determine how many files there are and when to stop.

 

I am also not sure whay you are incrementing in a shift register. Simply wiring to [i[ and add a "+1" would do the same.

 

To get a single column, use index array, not "delete from array".

Message 9 of 12
(6,546 Views)

I will implement all that you have suggested.

Thanks,

Ron

0 Kudos
Message 10 of 12
(6,544 Views)