LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help reading binary file

Solved!
Go to solution

Hi,

 

Just hoping that someone might be able to help me out with the following. i am new to labview and do not have a IT background so understanding binary files and how to read them is proving beyond my abilities.

 

Quite simply i am trying to open a series of binary files written in the following format (refer to data.txt attachment) and then within labview process the data. I have tried the read from binary file examples but seem to be going round in circles. I have also attached examples of the file format 8sept4.3ld and then the same file in an ascii format which is what i would like the output in labview to look like.

 

I would really appreciate any assistance with this, particularly if it is an idiot's guide!

 

Cheers,

Kath

Download All
0 Kudos
Message 1 of 22
(3,691 Views)
I really dont know 🙂 but did ur alias use to be d0efus somewhere else ?
T. A.
0 Kudos
Message 2 of 22
(3,664 Views)

Sorry but thats not me. 

 

You had my hopes up that you may have a solution!

 

0 Kudos
Message 3 of 22
(3,643 Views)

Based on the format, there is no "easy" way to read those binary files. The header is different based on what version of the file you're reading. However, the ASCII version is easy to read using the Read From SpreadSheet File VI. Can you not get the files in that format? If you're trying to write a converter you basically have to read a certain number of bytes at a time, as the spec calls out until you get to the Data Block, which can be read in as a full block of bytes, type casted, and then reshaped into an appropriate array. For example, the attached VI is just a started to read the first few elements of the header to give you an idea of what would be involved.

 


toniaz wrote:
I really dont know 🙂 but did ur alias use to be d0efus somewhere else ?

ur -> your  - we like to use full words on these forums instead of Twitter-speak. Thanks. Smiley Wink

 

Message 4 of 22
(3,642 Views)

doofus, sorry there 🙂 someone answered.

, thanks, but I do NOT see anyone else complaining, anyway, it slipped right away, I am used to writing full words.

Excuse me. 🙂

T. A.
0 Kudos
Message 5 of 22
(3,637 Views)

toniaz wrote:
, thanks, but I do NOT see anyone else complaining

I wouldn't say that ... http://forums.ni.com/ni/board/message?board.id=BreakPoint&message.id=6099&query.id=81357

 

Don't worry, now I'm just picking on you. Smiley Wink

Message 6 of 22
(3,631 Views)

Thanks smercurio_fc - you have put me on the right direction! We are currently exporting files from the program in ascii but this then means exporting a minimum of four files per trial which is proving a nightmare for undergrad students to keep on top of. I am hoping that if we can crack the default program files it will be a nice streamlined process.

 

I will work my way through it now that i know how to pick it apart.

 

thanks again!

0 Kudos
Message 7 of 22
(3,626 Views)

Well, good luck with it. It's not hard - just tedious. If I were doing it I'd probably put the conversion of the string to a number into a subVI with a small icon so I could reuse it and save diagram space. Note that the integer that's going into the Type Cast is a U16 since it's converting 2 bytes (WORD) into an integer.

 

It appears the data files are using little-endianness. By default, LabVIEW uses big-endianness when reading/writing binary files. Instead of the Type Cast and Byte Swap functions you can also set the endianness on the file reading, but you'll need to use an Index Array since the output will be an array of numbers:

0 Kudos
Message 8 of 22
(3,619 Views)
just a quick question - looking through the data file it refers to dword (for instance for the dataset offset). how do i read these sections?
0 Kudos
Message 9 of 22
(3,615 Views)
Depends on whether they're using the standard Windows API type defs. I assumed that when using a U16. Based on looking at the raw file it appears that is the case. Thus, a DWORD would be an unsigned int (U32).
0 Kudos
Message 10 of 22
(3,599 Views)