LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read numeric array from a text file

I'm new to file I/O in LabView. Basically, all I need is to read the attached 2000 x 9 array into an identical 2D array within LabView. I have tried simply using the READ FROM SPREADSHEET FILE VI but it only reads the first column. Any help would be greatly appreciated.
Thanks, Hunter
0 Kudos
Message 1 of 7
(3,576 Views)
Hi Hunter,

The problem you are seeing is because the file is not a tab de-limited file. By default the Read From Spreadsheet File.vi has a tab character as the de-limiter. If you change that character to a space character you will get a 2000 x 17 array, this is because some of the entries have a double space between them. You will need to process this file before you can achieve exactly what you want.

Hope this helps,

Nick
0 Kudos
Message 2 of 7
(3,576 Views)
Thanks for your thoughts, Nick. I was betting it must be something to do with the delimits. However, I'm unsure how I should "process" this file in order for it to be read. In MATLAB, I used the command:
save FRFx1.dat FRFx1 -ascii
0 Kudos
Message 3 of 7
(3,576 Views)
Hi Hunter,

Obviously the best solution would be to get the file in the appropriate format from MATLAB in the first place. I am not able to help you here as I do not use MATLAB, but attached is a vi to read in the file, perform the pre-processing and then give you the resulting 2000 x 9 array. It isn't the most elegant solution but it works for this file.

Hope this helps,

Nick
0 Kudos
Message 4 of 7
(3,576 Views)
I cant open theother examples, so maybe I`m posting something similar, but here`s my approach in LV 6.1

First convert all double spaces to single spaces, then all single spaces to tab. Then use "Spreadsheet string to array" cutting out the first column (extra tabs produce an extra column).

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 5 of 7
(3,576 Views)
Nick,
Appreciate the solution. Unfortunately, I'm running 6.1. But no sweat, Shane has helped me out below.
Thanks again and have a good weekend.
Hunter
0 Kudos
Message 6 of 7
(3,576 Views)
Works sweet, Shane!
Glad someone else is still using 6.1.
Have a great weekend,
Hunter
0 Kudos
Message 7 of 7
(3,576 Views)