LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recursive File List VI

Solved!
Go to solution

Let me start off with saying that i have little experience with Labview. It's limited to altering programs I use for my research that were written by others. I'm looking to automate a data processing VI that a collegue created. As of right now, when the VI is run, it prompts me for the file to be processed, does the processing, then prompts me to input a file name under which the results are saved. However, I have about 700 files that need processed, and would love to have it run itself.

 

I'm hoping to alter the file so that, instead of  prompting me for a single file, it prompts me for a folder, then processes any files it finds inside of that folder. I figure that the Recursive File List VI is a good choice, since it returns the files paths of anything within the folder in an array (if I understand correctly), but I'm not sure how to have the VI process these in turn.

 

BASICALLY, I need a way to select a folder, and have LabView feed individual files into an already existing data processing VI (the insertion point would be an "open file" function). Can I use the Recursive File List VI for this? If so, how do I have it process the files individually. If not, what should I be using?

 

Thanks a lot for the help.

0 Kudos
Message 1 of 6
(6,268 Views)
Solution
Accepted by topic author okeeffe

Yes, you can definitely use the Recursive File List VI. The input to this VI is the root folder that contains your files to be processed, and you can also wire in a "pattern" such as *.txt to obtain a filtered output (look under Detailed Help for the VI). The output of this VI is a list of file paths. Wire this list to a For loop, and inside the loop you will have sequential access to each item in the list. Inside the loop, wire the path to you processing algorithm. To automatically save the resulting data with an automatically generated file name, take the incoming path, parse it out, edit the string with the String Concatenation function, reassemble the path, and then use it to write a new file.

Message 2 of 6
(6,265 Views)

Here is simple code to get you started, in LabView 2010.

Download All
Message 3 of 6
(6,263 Views)

Thanks for the quick reply. I messed around with it a bit after writing this and came up with something that seems to work (an image of it is attached). Automating the saving process is the next step, definitely.

 

Right now I have the list of paths and the loop iteration number wired to an "index array" function. I was thinking the path list was in an array, and this way I would pull out an element with each loop iteration. Is this necessary? From what you've said, it sounds like the loop with take each element of the list in turn as it's passed into it. It seems to work now, so i guess it's not doing any harm, but any simplification would be nice, I suppose.

 

Thanks again.

 

[edit] To clarify, all I was trying to do in that piece is see if I could pull individual file paths out of the list. Once I get past that, I think I'll be fine doing the rest.

0 Kudos
Message 4 of 6
(6,261 Views)

What you have in the screenshot will sequentially get each file path from the list, but a cleaner way is to use the auto-indexing. Right-clicking on the spot where an array enters a For loop or a While loop will allow you to select whether indexing is turned on or off.

Message 5 of 6
(6,239 Views)

Oh, okay. That would explain why I couldn't get it to work initially. Thanks so much. I wasn't able to open the examples you posted, since the version I have is older, but the image helped as well. I had no idea the Strip Path and Build Path functions existed. I've got everything working now. Thanks again!

0 Kudos
Message 6 of 6
(6,234 Views)