Skip to main content
numpy-ts provides NumPy-compatible text parsing and serialization, split into environment-agnostic browser functions and Node.js file I/O functions.

Browser API

These functions work with strings and can be used in any JavaScript environment.

parseTxt

Parse a text string into an NDArray. Each row must have the same number of values.
Returns: NDArray — 2-D array (or 1-D if a single row/column).

serializeTxt

Serialize an NDArray to a text string.
Returns: string — Text representation of the array.

genfromtxt

Parse a text file with more flexible handling of missing values. Replaces missing values with a fill value instead of throwing.
Returns: NDArray — Parsed array with missing values filled in.

fromregex

Extract data from a text file using a regular expression with capture groups.
Returns: NDArray — Array with one row per match and one column per capture group.

Options Reference

ParseTxtOptions

SerializeTxtOptions


Node.js API

loadtxt

Load data from a text file on disk.
Returns: Promise<NDArray> — The parsed array.

savetxt

Save an array to a text file.
Returns: Promise<void>