LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I have to raed a "text file" with numbers that was seperates by commas & linefeed, how can I split them into an 1D-array of float numbers

I attach that text file with the above-mentioned, someone can help? Thanks
0 Kudos
Message 1 of 5
(3,101 Views)
1) Read in file with "Read from Spreadsheet File.vi" (on File I/O palette) with delimiter set to a comma
This will get you a 2d array with your numbers in it with a final column of zeroes (your file has lines which end in a comma followed by linefeed and carriage return which in spreadsheet terms is assumed to be an empty column)
2) Remove the column of zeroes with the "Delete from Array" function (Array palette)
3) Reshape the array from 2d to 1d with Reshape Array function (Array palette)

Example vi (LabVIEW 6.1) attached

Ian Bell
Message 2 of 5
(3,102 Views)
Hi Iangbell,

Thank you for your excellent advice (even I could not see your file (mine is 6.0 not 6.1). But by following your steps, I am able to do as you adviced beautifully.

Thank you very much!
0 Kudos
Message 3 of 5
(3,101 Views)

I have a similar situation. Instead of displaying all the data at once I want to step through the data and compare each number with another number. Here is an example of what i am talking about. Lets say my text file contains the following

12345

56789

98765

54321

I want to go through each of these line and compare each number to a number inputed by a user. How would I step through the array?

0 Kudos
Message 4 of 5
(2,910 Views)

Use a For Loop with auto indexing enabled.

Message Edited by AndrewAlford on 03-02-2007 12:13 PM

Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
0 Kudos
Message 5 of 5
(2,904 Views)