0

I want to save a large uint8 numpy array for use later. How can I do that using the least amount of storage possible?

Edit: Encoding the file in UTF-8 or ASCII makes the file way larger than it needs to be.

WyattBlue
  • 401
  • 1
  • 4
  • 17
  • 1
    Both questions that mark this as duplicate have essential differences in their main objectives. While in this question the OP is concerned about "storage usage", in https://stackoverflow.com/questions/6081008/dump-a-numpy-array-into-a-csv-file the concern is "csv format" (larger than any binary file as mentioned) and in https://stackoverflow.com/questions/9619199/best-way-to-preserve-numpy-arrays-on-disk the concern is "speed on saving" (if fast is not going to be very efficient on storage usage) – Gonzalo Matheu Aug 02 '20 at 01:17

1 Answers1

2

Numpy's save_compressed will save the array into a npz file using zip compression.

Apart from being compressed, it allows you also to save multiple arrays into the same file which might help you to save some space as well

Gonzalo Matheu
  • 6,511
  • 4
  • 29
  • 49