Skip to main content

NumPy Format

Read and write NumPy .npy / .npz arrays as flat row dictionaries.

Overview

PropertyValue
Format idnpy (alias npz)
ClassNumPyIterable
Extensions.npy, .npz
ReadYes
WriteYes
Extranpy (numpy)
Maturitystable

Record shape

Array rankRecord
1D{"value": scalar} per element
2D{"col_0": ..., "col_1": ..., ...} per row

Only 1D/2D arrays are supported. Requires a filename (not a stream).

Parameters

ParameterDescription
array_nameFor .npz, array to iterate (default: first); used on write as the saved name

list_tables() returns array names for .npz (or None for .npy). totals() is the leading axis length. Writes buffer rows and flush on close().

Usage

from iterable import open_iterable

with open_iterable("matrix.npy") as source:
for row in source:
print(row)

with open_iterable("data.npz", iterableargs={"array_name": "X"}) as source:
for row in source:
print(row)

Install with pip install iterabledata[npy].

See also