LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to open all the text files within a folder at once so that they run through my VI in the correct order and the VI only needs to be ran once per folder?

Solved!
Go to solution

Hello,

 

I am currently attempting to run hundreds of text files through my VI by only having to run the VI once and having labview open each text file in numberical order that are contained in a single folder.

 

Typically, I run each file one at a time through the VI, taking hours to run all the text files through. I was wondering if there is a way that I can specify a target folder and then each text file from the target folder will be opened and ran through my VI  in numberical order (each file is in order i.e. MM_01, MM_02, MM_03...). Currently I open one file at a time, run it through "read from spreadsheet", then index the array, and run it through filters etc. to obtain the data I require. I am hoping there is a way to do this, as it will save days worth of work.

 

Thank you in advance for your help.

0 Kudos
Message 1 of 18
(6,980 Views)
Solution
Accepted by CSmith8

Capture.PNG


"Should be" isn't "Is" -Jay
Message 2 of 18
(6,970 Views)

Are you just wanting to read all of the files within a folder then close them again after getting the data?

 

Just use the List Folder VI from the File IO pallette. You can input a pattern like "*.txt" to get all files of a certain type within that folder. Then fun that array of filenames into a For loop, Build Path with the original folder path, and Read from Spreadsheet.

 

Edit: Do what JeffP gave you. If you don't want the files within subfolders, do this:

Open Files In Folder.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 18
(6,967 Views)

Thank you for a quick response.

 

How do you suggest i resolve the issue of different data types in order to use this function? I have tried a few different ways and have whenever I adjust, it wont run through my sub VI's correctly due to being different data types.

0 Kudos
Message 4 of 18
(6,912 Views)

What different data types? The For loop is indexing through the array one by one, so you don't need to do an Array Index operation.

 

The snippet I included above should make it clear what to do once inside the For loop.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 18
(6,904 Views)

@CSmith8 wrote:

Thank you for a quick response.

 

How do you suggest i resolve the issue of different data types in order to use this function? I have tried a few different wa