08-04-2010 07:57 AM
Hi,
I'm trying to write a vi that reads a file, calculates mean, std, and etc per column and then saves it to a new file.
I get an error at "Scan From String Function" which I can't find a way to resolve.
Also, after constructing the array, is it possible to find the mean, for example, of each column with out breaking down the array?
I've attached my vi so far and a sample txt file.
Thank you,
Solved! Go to Solution.
08-04-2010 09:40 AM
You have several issues:
Aside: Wouldn't it be easier to simply use the Read From Spreadsheet File VI?
08-04-2010 10:03 AM
Thank you for your reply smercurio_fc.
ok, lets assume the input file is a spreadsheet not txt, I'm still not sure how to do operations by columns (like mean of a column).
How will it be different?
08-04-2010 10:13 AM
A text file with delimiters is a spreadsheet file.
Look at the help for Read From Spreadsheet. The 'All Rows' output is a 2D array. Just index each column (Index Array function with the column input wired).
08-04-2010 10:16 AM
The Read from Spreadsheet File reads text files, not Excel workbooks. This VI has been badly named from the start, and it confuses new people all the time. We've lobbied NI to change the name, but it has fallen on deaf ears. The VI will simply read in your file as a 2D array directly. You can then index out whatever columns you want to average, or if you want to do it for each column you can transpose the array and simply autoindex:
08-04-2010 11:50 AM
Thanks again for your comments.
I always thought that spreadsheet means excel, so I didn't even bother checking it out. It is a confusing name indeed.
I've tried both suggested vi's, but the second vi (with the for loop) didn't work because of different dimensions I believe.
So I've using this vi (see attached file), how can extract the next row?
Since I have 5-6 rows, I would hate repeating the same process for each one, isn't there a way to create an array with the mean of each column (as one entry)?
08-04-2010 11:56 AM
Don't use the First Row (1D) output. Use the 2D (as mentioned) which is the entire file.
Please turn on Context Help. You will save a lot of time if you read the information in that window.
08-04-2010 05:22 PM
The thing is that the 2D method doesnt work, when I try to construct the suggested vi.
Please see attached file.
08-04-2010 05:25 PM
You are not listening (or in this case reading). Use the 2D array output (called "all rows), NOT the 1D array output.