npyz 0.9.0

NumPy file format (de-)serialization. Fork of outdated npy-rs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fs::File;
use std::io;

// test-data/plain.npy is generated by this Python code:
//
// import numpy as np
// a = np.array([1, 3.5, -6, 2.3])
// np.save('test-data/plain.npy', a)

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = io::BufReader::new(File::open("test-data/plain.npy")?);

    let npy = npyz::NpyFile::new(file)?;
    for arr in npy.data::<f64>()? {
        eprintln!("{:?}", arr?);
    }
    Ok(())
}