LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading multiples files from a folder and processing

Hello everyone,

 

Im working on a project to analyst and process Acoustic Emission Signals. My problem is that I have a folder that containts several files .txt. Every file contains 16 waveforms (16 channels) that I need to process with an equation to detect the arrival times of the waves.

I have been working in this way : Running the labview code that open the file that I select .. then the processing happens on every wave and I click stop to select the file where I want to save the solutions. The solutions is only a vector of the 16 arrival times detected. Then I have to stop the code (by clicking Abort Execution) and repeat the process ... Run the code and bla bla bla .. and save on the same solution file that I used before.

The ideal situation is to read the files whitout stoping the execution of the code .. For example clicking a buttom to pass to the next file and saving all the solutions to the same file. That is beacause sometimes Im going to have more than a 100 files and this will give me a hard time if a forget in which file I was working. The idea is to make an automatic process.

 

Please .. I have been trying to find a solution to this while Im working in other part of the code. If someone could suggest me a solution it would be great.

Thanks.

 

0 Kudos
Message 1 of 8
(5,456 Views)
Can you post your code or an example of your code, It will be easire to help that way. What version of LabView are you using?
Tim
GHSP
0 Kudos
Message 2 of 8
(5,445 Views)

What version of LabVIEW are you using?
I dont remember when it started, but LabVIEW has a recursive file reading function.

You just specify a folder, and it outputs an array of files in that folder.

 

recursive.PNG

 

Using a For loop, you can iterate through the list of files, and perform the same code automatically.

Cory K
0 Kudos
Message 3 of 8
(5,442 Views)

Alvaro_ortiz,

 

1. Do not use the Abort execution button to routinely stop  a VI. It is intended for a programmer to halt a runaway program.

 

2. Look at examples of state machines.  A simple state machine implementation consists of a while loop containing a case structure.  The State variable is connected to the case selector and a shift register.  The state is often implemented as type def'ed enum.  You might have states for Select File Folder, Open File, Process data, Save Solutions vector, and Exit.

 

Lynn 

0 Kudos
Message 4 of 8
(5,439 Views)

Hello everyone,

 

Well Im sorry if I didn't post my .vi ... I was working on it ... and I found a solution (whit some help that I found on the forums) but Im not happy at all ... because I still have to give the last part of the file name.

For example at the beginning I have to input the file name without the final number of the event ...

 

C:\Users\Irish\Desktop\Hydraulic Fracturing\E1_evento

 

then I finish adding the file number that I want to process on the folder

 

C:\Users\Irish\Desktop\Hydraulic Fracturing\E1_evento2.txt or 9.text or ... just the number ...

 

This is the case when I want to process every file specifying the file .. but what could you suggest me to do process all the data file by file ?

 

I attached the part of the code that Im using for this specific problem ...

Im using Labview 8.5

 

Thanks ...

Message Edited by Alvaro_Ortiz on 08-26-2009 03:14 PM
0 Kudos
Message 5 of 8
(5,419 Views)

Do you want to combine all the arrays into one array?

If so, you could do something like this:

 

read fiile.PNG

Cory K
0 Kudos
Message 6 of 8
(5,406 Views)

Hey Cory thanks for your help ... but actually my problem is not to combine all the files in a bigger file .. If I do it in that way I will need to process all 16 channels (that are contained in every file) multiplied by the number of event (that could be 100's). I still think to process every event by event with just a click (something like a button that says next event) and that also save the solution all the solutions on a file. I working on it .. and everyone is invited to make suggestions .. I will post whatever I could do ..

 

By the way somebody knows how to save on different columns on excel or txt file ? ... I mean I am creating a column with 16 solutions of every wave for every event. At the end this file is going to contain as many files than events that I have.

I have to do it manually ..

 

I also attached a picture of the process for a better understanding ..

 

Thanks .. 

0 Kudos
Message 7 of 8
(5,380 Views)

There is no easy way to add columns to a file.  Files are just a sequence of bytes and by convention they start at the upper left corner and go right.  Visually they go down a row when and End of Line character is encountered.

 

To add a column you would need to read in the entire file, find the end of each row, insert the new element at the end of the row and then rewrite the file.  Inserting bytes means moving all the subsequent bytes and possibly reallocating memory (because the string or byte array is growing).

 

An easier way is to add a new row for each event.  If you need the column format, when you have completed the analysis, read in the file once as a 2-D array, transpose the array and write it back to the file (or to a different file).

 

Have you looked at the state machine architecture I suggested earlier?

 

Lynn 

0 Kudos
Message 8 of 8
(5,361 Views)