07-21-2015 11:06 AM
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.
Solved! Go to Solution.
07-21-2015 11:11 AM - edited 07-21-2015 11:12 AM
07-21-2015 11:12 AM - edited 07-21-2015 11:14 AM
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:
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
07-21-2015 01:52 PM
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.
07-21-2015 01:55 PM - edited 07-21-2015 01:58 PM
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> ---'
07-21-2015 01:56 PM
@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 ways and have whenever I adjust, it wont run through my sub VI's correctly due to being different data types.
You have to READ THE FILES. Jeff just showed you how to use a FOR loop to go through the files. You still need to open the files, read them and then process the data.
07-21-2015 02:32 PM
Thank you, I missed though and thought that opening the files did that for me. I now have it working and running my files through while they are matching the ones I ran individually.
Thank you all for your help!
07-21-2015 02:32 PM
@crossrulz wrote:
@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 ways and have whenever I adjust, it wont run through my sub VI's correctly due to being different data types.
You have to READ THE FILES. Jeff just showed you how to use a FOR loop to go through the files. You still need to open the files, read them and then process the data.
I had assumed from CSmith8's original post that the text file processing vi worked. just drop that vi into the for loop and wire the file name in!
Alternately, attach the code that processes the file and a sample file. I bet we can show you a thing or two about how to do it cleaner and faster then point you to the right learning resources so one day you can show us some new tricks.
-Old Dog Jeff·Þ·B
(Why does everyone forget the commas? alt+0183 alt+0222 alt+0183)
07-22-2015 07:49 PM
hi i tried to run the vi but i keep getting an error which says "file is not a resource file". the error is highlighting the list folder vi. can you help me fix this?
07-23-2015 08:42 AM
Hi ceciliap004,
Could you post a screenshot of the code you are trying to run. What kind of file are you trying to open?
Please provide more information about the issue you are having.
Regards,
Carolina