Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

Reading data form binary .bin file in Python: how can I decode floating point values?

I am quite new to programming with Python and data analysis.

Let me introduce my problem: I have a binary file .bin which contains some data about telemetry from a satellite, and I need to extract just some of this data. In order to know what data I need to extract I have a .csv file which tells me the Hexa Adress, the bytes and the data type in which it is contained (At least this is what I have understand so far).

I have managed to just open the data and load it, but I don't even know what do I need to do, first to decode this binary data and then to extract the one I have.

import struct

path = 'C:/Users/Jose Herrera/Downloads/telemetry.bin'
file = open(path, 'rb')
data = file.read()

file.close()

.csv content. I need to find the data in gray

So, I am trying to get this data from struct.unpack('III', data[124:136]), but I am not sure if this is correct as I get (1354956800, 0, 0) as result. I think this should be floating point, but I don't know how to unpack or decode these values.

question from:https://stackoverflow.com/questions/65831431/reading-data-form-binary-bin-file-in-python-how-can-i-decode-floating-point-va

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...