LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having problems reading a binary* file

Hello guys,

 

A third party sw tool measures some parameters from a battery and outputs a file (which iam thinking is binary). The same sw tool also has the capability to convert this file to a .txt file.

Iam trying to read this (binary file) to avoid having to do the conversion on the (sw tool) it self.

 

i tried to follow a similar approach as this post here but no joy.Capture.PNG

https://forums.ni.com/t5/LabVIEW/Binary-file-of-unknown-formats/td-p/512870

 

any help on this will be appreciated.

 

kind regards

 

 

 

 

Download All
0 Kudos
Message 1 of 15
(3,000 Views)

Hi El_Tipo,

 

it would help when you would attach this "binary" file instead of the already converted text file! (ZIP it…)

And even better would be to also attach a description of the internal file format of this "binary file"…

 

I tried to follow a similar approach as this post here but no joy.

Well, that would only makes sense when your "binary file" uses a very similar encoding (aka file format) as the file in this 11 year old thread! That's why I asked for a file format description…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(2,995 Views)

GerdW,

 

Thanks for the reply.

I of course failed in adding the file of interest.

 

attached you can find the file.

the actual description i do not know it other than what the .txt file already provides.

let say that the number of columns is never going to change.

0 Kudos
Message 3 of 15
(2,957 Views)

i cant send this file through here.

i have tried to zip it, to send it raw, to zip it and renaming the extension from .rar to .par no joy.

Capture.PNG

is there any other way for me to upload this file?

 

0 Kudos
Message 4 of 15
(2,946 Views)

Looking at your file, I see that a typical row in your table reads like:

1	0	1	  0d 00:00:0	  0d 00:00:0	0	0	0	13.551	R	0	04/16/2018 8:41:07 AM	0.00000	0.00000	300	10	0b0110000000000001	0	65535	0	65535	0	1	21.5	13.553	0.000	0.000	1	13	13	554	4553	65535	65535	65535	1.200	16.800	0b0000000011000000	43	0b0000000000000000	3391	3385	3390	3387	0	0	0.89906	 C  	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	0.00000	

I don't think you can easily have LabVIEW read that as a double. What happens if you first read the entire thing in as a string?


@El_Tipo wrote:

i cant send this file through here.

i have tried to zip it, to send it raw, to zip it and renaming the extension from .rar to .par no joy.

Capture.PNG

is there any other way for me to upload this file?

 


Could you save your binary file with a .txt extension? I don't think zipping it is actually necessary.

0 Kudos
Message 5 of 15
(2,936 Views)

Hi Tipo,

 

why has your file a 'rar' suffix when you ZIP it? Please ZIP the file!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 15
(2,933 Views)

"Binary" does not mean anything specific. Everything involving computers is binary one way or another.

 

Place your LabVIEW code AND the binary file in a zip file and attach it here (in windows explorer, select the files then right-click...send to... compressed folder (don't do weird things such as RAR or similar)). The forum accepts zip files just fine, independent on how you are naming the binary file inside it. The code would be interesting because your image is very ambiguous. Apparently, the file is not completely binary data, because you read some of it as text so there seems to be a a header.

If you add a diagram comment like "this is what I guess...", we can't even tell if your constant is SGL or DBL or even complex. Do you know it is little endian? What is the purpose of the last read operation? What's up with all these coercion dots?

0 Kudos
Message 7 of 15
(2,920 Views)

@altenbach wrote:

 

If you add a diagram comment like "this is what I guess...", we can't even tell if your constant is SGL or DBL or even complex. 


Agree with everything, except we know the constant is a DBL 🙂

Message 8 of 15
(2,917 Views)

True, if  we follow the wire all the way to the indicator, far away from the comment. 😉

 

We still don't know if DBL is correct. 🙂

0 Kudos
Message 9 of 15
(2,913 Views)

okay, here is the file zipped.

Altenbach,

 

I assumed that the file had a header that could be readable with the read txt files. i was wrong.

the image that i attached was what i found to be the closest scenario on the forum to what i was trying to accomplish here. this happened to be the VI you created on that particular post (with minor changes- but wrong nonetheless)

I tried to guess what was the size of the first three rows of the file (which has the information that i dont care about) and then using your approach i tried to then read the 2D array of the rest of the file, but the values are completely off.

 

0 Kudos
Message 10 of 15
(2,908 Views)