LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading channel headers

Hi, I have a file in the following format:
 
Ch1_NAME
Shot number
number of samples
time         data
time         data
time         data
time         data
....
Ch_2NAME
Shot number
number of samples
 
...etc
 
An example of which is attached. I want a VI that creates an array of data, time, channel names and shot numbers. I can do all apart from the channel names part. There doesn't seem to be an easy way to create an array of strings in the same loop as array of numbers. Is there a funcion that allows the reading of strings and floats? I have attached my VI, I wonder if anyone knows an easier way to read this type of file?
Download All
0 Kudos
Message 1 of 10
(3,406 Views)
Hi phuech,

I would do as follows:

1) read in 3 lines of text
2) parse those 3 lines to get name, shot, #samples (using "scan from string" with format string "%s %d %d")
3) read in #samples lines of text and convert to time/data array(s)
4) start again with 1) until EOF

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(3,399 Views)
Thanks very much for your reply. 'Read lines from text file' outputs an array of strings. Do I need a seperate function to change this into one string? As scan from string won't accept an array.
0 Kudos
Message 3 of 10
(3,388 Views)
Hi phuech,

interesting - at the moment I only get a long string... You should note which LabView version you are using!

Anyway: use 'concatenate string' to convert an array of strings to one string.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 10
(3,386 Views)
Very sorry. Labview 8.2.1 Full development system. Is there any chance you could put up a quick example VI so I can see how you read out the data. I can't get the read lines function to start a number of lines into the file, which is needed to read the data and time arrays, or indeed to read the next channel.
0 Kudos
Message 5 of 10
(3,381 Views)
I got it work. I have attached my VI. I have a major concern that it appears to be a very slow method of achieving what I want. it takes around 2 seconds to read one channel. Multiply that by 32 and we have more than a minute to read a file! Maybe I haven't quite understood/made a mistake?
 
 
Thanks
Phuech 
0 Kudos
Message 6 of 10
(3,370 Views)
Hi Phuech,

I changed your vi a little bit... Now it returns an array of cluster, each containing name of sample and sample data.

You made no (big) errors - but you didn't code according to speed Smiley Wink It's not a good idea to create new strings in every iteration.
It's better to use the scan offset instead or to read just the part of the file you need next...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 10
(3,364 Views)

Thank you very much for your help and patience. Your mod is almost perfect but it doesn't appear to output the time series data... Other than that, it reads much quicker. I can't imediately see why the time series is not coming out because your mod appears to have a similar form as "read spreadsheet file" which does output both. 

I didn't really realise I was creating a string every itteration, but now I have yours for comarison it appears a much more elegant way of doing it.

 

Thanks,

Phuech

0 Kudos
Message 8 of 10
(3,361 Views)
Hi Phuech,

it's hard to get 5 stars in this thread Smiley Wink

Well, yes there's an error in my last vi. Maybe the 'convert spreadsheet string' doesn't like your UNIX-style end-of-line character (just 0x0a instead of MS-DOS 0x0d0a)...
So I rewrote this part, it's not as elegant as before but now it works Smiley Happy
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 10
(3,342 Views)

Thanks a lot. That works fine. You've been a great help. 5 stars.Smiley Happy

 

Thanks again

Phuech

0 Kudos
Message 10 of 10
(3,333 Views)