def _npz_headers(npz, namelist=None):
    "\n    taken from https://stackoverflow.com/a/43223420\n\n    Takes a path to an .npz file, which is a Zip archive of .npy files.\n    Generates a sequence of (name, shape, np.dtype).\n\n    namelist is a list with variable names, ending in '.npy'. \n    e.g. if variable 'var' is in the file, namelist could be ['var.npy']\n    "
    with zipfile.ZipFile(npz) as archive:
        if (namelist is None):
            namelist = archive.namelist()
        for name in namelist:
            if (not name.endswith('.npy')):
                continue
            npy = archive.open(name)
            version = np.lib.format.read_magic(npy)
            (shape, fortran, dtype) = np.lib.format._read_array_header(npy, version)
            (yield (name[:(- 4)], shape, dtype))
taken from https://stackoverflow.com/a/43223420

Takes a path to an .npz file, which is a Zip archive of .npy files.
Generates a sequence of (name, shape, np.dtype).

namelist is a list with variable names, ending in '.npy'. 
e.g. if variable 'var' is in the file, namelist could be ['var.npy']
def _npz_headers(npz, namelist=None):
    "\n    taken from https://stackoverflow.com/a/43223420\n\n    Takes a path to an .npz file, which is a Zip archive of .npy files.\n    Generates a sequence of (name, shape, np.dtype).\n\n    namelist is a list with variable names, ending in '.npy'. \n    e.g. if variable 'var' is in the file, namelist could be ['var.npy']\n    "
    with zipfile.ZipFile(npz) as archive:
        if (namelist is None):
            namelist = archive.namelist()
        for name in namelist:
            if (not name.endswith('.npy')):
                continue
            npy = archive.open(name)
            version = np.lib.format.read_magic(npy)
            (shape, fortran, dtype) = np.lib.format._read_array_header(npy, version)
            (yield (name[:(- 4)], shape, dtype))