LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Average data from 50 text files

New to Labview and needing help with data that I am acquring and writing into multiple, sequantially numbered text files. The text files have 2 columns of data and I would appreciate an example code to read and average the data from 50 such text files.

 

Thanks. 

0 Kudos
Message 1 of 12
(3,608 Views)

This Forum is primarily to help you learn to write your own LabVIEW programs and not to write code for you.

 

There are many ways to do what you asked and they will produce different answers.

 

1. What is the format of the data in the text files?

2. Are the columns to be averaged separately or do they get combined in some way?

3. How large are the files?

4. Does each file have the same number of data points or do they vary?

5. How do you want the program to select the files?

6. What do you want to do with the average or averages?

7. How should errors be handled? Missing files? Data format errors? Infinities, NaNs, or other non-numerical data?

 

 

What parts have you tried? What has worked? What did not work and what kinds of errors did it produce?

 

Lynn

 

0 Kudos
Message 2 of 12
(3,604 Views)

Hi Lyn,

 

I can read a single file using the labview read from the express tab. If I split the data coming out of the file, I can manually adda the data in each of the files and then average it. Its a cumbersome process for 50 files hence asking for help in reading from 50 text files and averaging. Believe me, I have already tried. The files have 2 columns each and the number of rows is 2000 - constant for each file. The files are wirtten as data_001.lvm, data_002.lvm etc. The fancy stuff on what to do with missing files should be for later when I understand Labview a little better. The program should be given the folder name and the the 1st file. It should also be given the starting point, eg data_001.lvm and then it adds the next 49 files and takes an average and output it to a file.

 

Thanks.

0 Kudos
Message 3 of 12
(3,600 Views)

OK.

 

List Folder function on the Advanced File Functions pallette will get you a list of all the files in a folder.  The File Dialog from the same palette will geive you a nice user interface to locate the folder containing the files.  If there are other files in the folder which you do not want to include in the averages, you will need to do some manipulation of the paths or search through the array filenames produced by List Folder.

 

Once you have an array with the desired filenames, wire it into a for loop with autoindexing enabled. Inside the loop use Read From Spreadsheet File.vi or Read From Measurement File to get the data as a 2D array.  Create a shift register initialized with a 2D array of zeros having 2000 rows and 2 columns. Add the data you read from the file to the shift register on eahc iteration. When the loop stops, divide by N to get the average.

 

Lynn

Message 4 of 12
(3,590 Views)

Are there any examples of such a use. I still do not know how to implement the steps you have outlined.

Hopefully someone else might be able to help.

 

Thanks.

0 Kudos
Message 5 of 12
(3,584 Views)

@tchando wrote:

Are there any examples of such a use. I still do not know how to implement the steps you have outlined.

Hopefully someone else might be able to help.

 

Thanks.


A kind suggestion do not use sentences like this I feel little uncomfortable with that since the reply was very clear. Lynn has provided good step by step instruction for performing what you wanted. If still you have problem post the vi that you have developed (in 2009 version) so anyone can help you out easily.

 

Good luck

-----

The best solution is the one you find it by yourself
Message 6 of 12
(3,568 Views)

For a newbie to Labview (just a day with Labview), what seems like a simple step-by-step procedure to a long time user - might still be daunting. I got thrust into Labview by some data acqusition mechanisim that was borrowed. While with time, I will get to know all the details, at this juncture I am looking for something that works. I have attached a simple code that works. It would be fine if I had 10 files - but I do have 50. Labview has a trove of examples that I thought I could take advantage only if someone would be kind enough to point to one if they know it. Or just a pictorial diagram of how a simple call would be wired.... With the example code I show, how can I put it into a loop so I can do the same for 50 files.

 

Thanks.

0 Kudos
Message 7 of 12
(3,558 Views)

Here is a simple example on how to do with a normal spreadsheet file.

 

Average from file.png

 

Good luck

-----

The best solution is the one you find it by yourself
0 Kudos
Message 8 of 12
(3,554 Views)

Thank you.

0 Kudos
Message 9 of 12
(3,527 Views)

I also recommend that you look at the on-line resources for learning LV.  Spending a small amount of time now on those will help you learn the basics much faster and also help you avoid a lot of mistakes.

 

Lynn

0 Kudos
Message 10 of 12
(3,514 Views)