LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to modify my Vi so that it can read any number of input text files [without further modifying it each time]

i have build a VI which will take the header [selected portions] and the integer columns from input [process it according to certain equations] from input text files, and write it back to a text file.

At present my VI takes two input files.

The data from second file is saved next to [right side] of first file.

How to modify my Vi so tht it can read any number of input text files without further modifying it each time depending on the number of inputs.

 

I have attached the VI [all sub vis and input, final save file]

 

Thank you

0 Kudos
Message 1 of 4
(4,886 Views)

I am not clear on exactly what you want.  Does the program you posted work correctly for two files?

 

You keep reading and writing the file over and over.  This seems like a lot of duplication of effort. It may increase the chances of file corruption.

 

I would approach the issue this way:

 

1. Create an array of the input file names/paths.

2. In a for loop read each file exactly one time.  If you need to access the contents in multiple places, pass the string (or array of strings) around.  Extract the data you want in the final file and place it in an array in a shift register.

Note that it is much less likely to cause memory allocation problems if you intialize an array to a size larger than the maximum amount of data you need before you enter the loop then use Replace Array Subset inside the loop. Because you can determine the number of input files from the size of the array of paths, you can reliably estimate the size of the array.  The use of Insert Into Array can cause frequent memory allocations and may lead to crashes as the size of the array grows.

3. After exiting from the for loop, write the final file exactly one time.  You may need to do some string formatting before the write.

 

Do not use sequence structures.  They are the least adaptable structure in LabVIEW.

 

Do not have separate file path controls for each input file. If manual entry is required, use an array of controls.  It can grow to any practical size. A better approach might be to create a folder/directory containing only the input files. The File/Directory Info function (in the Advanced File Functions palette) can generate the array of file paths.

 

Lynn

 

Message 2 of 4
(4,841 Views)

Really thanks for the reply, am new to labview platform

My vi works fine for two files..but i want it to automatically take more than two files in a folder or zip folder and perform the task[which it performs fine on two files now].

Output will be a text file with data taken from the input files. The attached text file has saved data from input files.

0 Kudos
Message 3 of 4
(4,822 Views)

You really are new to LabVIEW.

 

Time for some basics.  LabVIEW has an "Auto-Indexing" For loop input tunnel.  this will cause a loop to iterate For every value in an array. 

Seperate Array Values.vi is one shipping example that uses Auto-indexing tunnels. 


"Should be" isn't "Is" -Jay
Message 4 of 4
(4,796 Views)