
Untitled
By: a guest on
Jul 6th, 2012 | syntax:
None | size: 0.44 KB | hits: 12 | expires: Never
Can I add extra header information to a numpy .npy file by using seek?
from tempfile import TemporaryFile
outfile = TemporaryFile()
# Write header to first 'n' bytes.
...
# Write the array after the header.
outfile.seek(n)
x = np.arange(10)
np.save(outfile, x)
# Then to read it back in:
outfile.seek(0)
# Read the header.
...
# Read the array.
outfile.seek(n)
y = np.load(outfile)
foobar.npy
foobar.meta
foobar.npy
foobar.npy.meta