1

I have a list of float32 numbers stored as BLOB on MySQL, I have the following script to read it from my database, it looks like mydata is of type bytearray, how can I convert it to a list or Numpy array of type float32?

query = ("SELECT mydata FROM mytable LIMIT 0,100")
cursor.execute(query)

for (mydata,) in cursor:
    print mydata  # bytearray(b"\xbe\xefe\x00#\xdf\x10\x...

Thanks!

1 Answer 1

1

np.frombuffer(mydata, dtype=np.float32) seems to work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.