LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a 3rd party data file with a mix of data types

Hi everybody,
 
Our faculty has recently purchased a couple of advanced, custom made, DAQ-devices. The hardware is fine, the software still has a lot of bugs. To circumvent the buggy software I am developing a LabVIEW-application that reads the raw datafiles. The datafile-format is a mixture of string, boolean, real and integer values. For example: 20 bytes of the file are a string, the next byte is a boolean, followed by a couple of integers. I've tried a couple of approaches:
 
First I tried the 'scan from file'-vi. Using the option 'edit scan string' I configured the vi to read the first 21 characters of the file as a string, followed by the next 11 and the next 41 characters (see illustration). However the vi also interprets the non-printable characters, such as 'line feed' (0A) and so it corrupts the output string.
 
The second method I tried worked better, but is far more tedious. Using the 'slice string'-vi from the OpenG-toolkit I tell LabVIEW wich bytes to read and wich to ignore (see illustration). This way I can ignore characters such as 'carriage return' (0D), but it is giving me a headache because I have to repeat this action many times and if I miscalculate the byte-offset, my output string is wrong.
 
What approach would you choose to read a 3rd party file with a mix of variables and data types? Thanks for your help/suggestions.
 
Sincerely,
 
Paul Perreijn
 
Biometrie, Hogeschool Zuyd
The Netherlands
0 Kudos
Message 1 of 4
(2,607 Views)
First off, method 1 probably needs to have the spaces removed between elements.
Questions:
Does this file have multiple lines? 
Are you sure that they are fixed length? If so, why are you worried about offsets?  I am not clear on that.
Is there a delimiter field that you can key off of? 
 
An example datafile would be helpful. But off the top, I have attached an example. LabVIEW 7.1.1

Paul
0 Kudos
Message 2 of 4
(2,591 Views)
Pict of diagram

Paul
0 Kudos
Message 3 of 4
(2,589 Views)

Thanks for the fast reply. Yesterday I spoke with the designer of the software that produces these datafiles. The format is more complicated than I thought so I will try to make it clear.
The first byte of every string field in the datafile defines how long the string is. For example: when a string is preceded by the byte 0A it does not mean 'line feed' (although LabVIEW will interpret it as such) but the decimal number 10. This means that the following string will be 10 characters long. Non-string fields, such as boolean, real and integer, aren't preceded by a byte that tells you how long the following field will be.
An example of what the first part of my datafile looks like can be found in the attachment. In this example you can see three fields: the first (DAQDV 0001) and second (proefperso) field are preceded by the byte 0A, because they are 10 characters long. The zeros between the first and second field are 'filler', because the first field can be 20 characters long. The third field is preceded by the byte 06, because it is 6 characters long.
I'll have another go at adjusting my vi, but suggestions are welcome. Thanks in advance.

Sincerely,

Paul Perreijn

Biometrie, Hogeschool Zuyd
The Netherlands

0 Kudos
Message 4 of 4
(2,567 Views)