I have a byte string that I would like to read into python. the string is a float conversion from numpy float64 to bytes.
The problem is that some of my data when converted ends up having the line break ‘n’ character as a byte.
How do I stop python from going crazy when it comes across the “n” character
here is my data
value: np.float64 = np.float64(0.05476599186658859)
bytes = value.tobytes()
print(bytes)
save_path = "c:/mydata.bin"
save_path.open("wb")
save_path.write(bytes)
save_path.clost()
the result
b'x00x00x00xc0Inxac?'
now when I try to open, I receive the following problem
data_path = Path("c:/mydata.bin")
with data_path.open("rb") as data_chunk:
data = data_chunk.read(8) # 8 bytes so read first 8
print(data)
result
b'x00x00x00xc0In
I was originally using readline() but moved to just read() to try and fix this but it still kept cropping the last byte