Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open and view .npz file in Python

Tags:

python

numpy

I have an unknown .npz file and would like to see whats inside. I am very new to Python.

>>> import numpy
>>> b = numpy.load('data.npz')
>>> print(b.files)
['arr_1', 'arr_0', 'arr_3', 'arr_2']

How do I see what these arr_i contain (i.e. dimension, values, etc.)?

like image 934
Shinobii Avatar asked Jan 24 '18 18:01

Shinobii


People also ask

How do I open a Npz file?

You need a suitable software like nProtect from INCA Internet Co, Ltd. to open an NPZ file. Without proper software you will receive a Windows message "How do you want to open this file?" or "Windows cannot open this file" or a similar Mac/iPhone/Android alert.

What is Npz file in Python?

npz file format is a zipped archive of files named after the variables they contain. The archive is not compressed and each file in the archive contains one variable in . npy format. For a description of the . npy format, see format.


1 Answers

np.savez_compressed('filename.npz', array1=array1, array2=array2)
b = np.load('filename.npz')

And do b['array_1'], b['array_2'] and so on to retrieve data from each array.

like image 194
user15051990 Avatar answered Sep 19 '22 14:09

user15051990