LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting data string of varible length into multiple sections

Hi all.

I'm attempting to use LabVIEW to read multichannel data exported from a different data acquisition package. The exported data files (.txt) have the following general format:

Header Info
Header Info
First Channel Name
#
#
.
#

Second Channel Name
#
#
.
#

... and so on. The amount of data contained within each channel is the same for each individual data file, but can change between data files, and so finding an appropriate offset location from which to split the string needs to be automated.

Ultimately, what I'd like to do is place the data into a numerical 2D array.

Any thoughts?

Cheers,
Nate
0 Kudos
Message 1 of 3
(2,801 Views)
You could create a loop that reads in one line from the file. If your all your data are numbers, you could test the line for being a number. If True, append the number to your array (use a shift register). If False, skip to the next read a line. You could also test for the line matching a channel name, and then append the following lines to the array until you read a blank line or a new channel name. In other words, use some piece of info about the file that tips you off to the fact that you are reading data and not a header.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 3
(2,794 Views)
Instead of having multiple reads, I would suggest that you modify the read from spreadsheet file VI to read strings and use this to read the entire file at once into an array. Since your groups are of a fixed size within the file, you can use search array or a while loop to find the size of the first group (by finding the last item in it or the first one in the next group) and then extract the numbers and strings according to the size of the groups and place them into a 2D numeric array.

___________________
Try to take over the world!
0 Kudos
Message 3 of 3
(2,775 Views)