Open and View. Npz File in Python

Open and View. Npz File in Python

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.)?

4

2 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.

1

Python provides "npzviewer" to open .npz files

pip install npzviewer

npzviewer [-h] [-v] [npzfile]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.