Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

read-npy-file

Read npy files in javascript and convert them to array buffer, nested array and json

npy, numpy, Numpy, file, FileReader, filereader, reader, .npy, python, ArrayBuffer, DataView, DataArray, data

readme

read-npy-file

Install

npm i read-npy-file

Usage

import readNumpyFile from 'read-npy-file'
const dataArray = readNumpyFile('data.npy')
console.log(
    {
        // The DataArray result
        dataArray,
        // 'typedArray' is a TypedArray. see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
        typedArray: dataArray.typedArray,
        // The shape of the numpy array
        shape: dataArray.shape,
        // Converts the flat TypedArray into a nested normal array equivalent to what it would be in python.
        array: dataArray.toArray(),
        // Converts to json string.
        json: dataArray.toJson(),
    }
)