Skip to content
Advertisement

Load a npz in numpy from bytes

I have a npz file saved from numpy that I can load by using numpy.load(mynpzfile). However, I would like to save this file as a part of a binary file, packed with another file. Something like:

JavaScript

However, when reading back the npz I get an error. I have tried load and frombuffer, and both give me an error:

  • frombuffer: ValueError: buffer size must be a multiple of element size
  • load: ValueError: embedded null byte

What can I do?

Advertisement

Answer

The last line should be input1, not input2. Also, guessing from the error message, you forgot to put BytesIO.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement