11-25-2009 11:26 AM
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
Solved! Go to Solution.
11-25-2009 12:17 PM
11-25-2009 12:46 PM
Sorry but thats not me.
You had my hopes up that you may have a solution!
11-25-2009 12:47 PM
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.
11-25-2009 12:54 PM
doofus, sorry there 🙂 someone answered.
smercurio_fc , thanks, but I do NOT see anyone else complaining, anyway, it slipped right away, I am used to writing full words.
Excuse me. 🙂
11-25-2009 01:01 PM
toniaz wrote:
smercurio_fc , 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.
11-25-2009 01:11 PM
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!
11-25-2009 01:22 PM
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:
11-25-2009 01:25 PM
11-25-2009 01:36 PM