Latest 0.3.0
Homepage https://github.com/aleph7/HDF5Kit
License MIT
Platforms osx 10.10, ios 8.0
Authors

Swift 4.0 compatible

This is a Swift wrapper for the HDF5 file format. HDF5 is used in the scientific comunity for managing large volumes of data. The objective is to make it easy to read and write HDF5 files from Swift, including playgrounds.

Usage

This example shows how to open an existing HDF5 file and write data to an existing dataset.

import HDF5Kit

// Initialize the data
let dataWidth = 6
let dataHeight = 4
var data = [Double](repeating: 0.0, count: dataHeight * dataWidth)
for r in 0..<dataHeight {
    for c in 0..<dataWidth {
        data[r * dataWidth + c] = Double(r * dataWidth + c + 1)
    }
}

// Open an existing file
let path = "file.h5"
guard let file = File.open(path, mode: .readWrite) else {
    fatalError("Failed to open (path)")
}

// Open an existing dataset
let datasetName = "dset"
guard let dataset = file.openDoubleDataset(datasetName) else {
    fatalError("Failed to open dataset (datasetName)")
}

// Write the data
try dataset.write(data)

Reading data is really easy with HDF5Kit:

// Open an existing file
let path = "file.h5"
guard let file = File.open(path, mode: .readWrite) else {
    fatalError("Failed to open (path)")
}

// Open an existing dataset
let datasetName = "dset"
guard let dataset = file.openStringDataset(datasetName) else {
    fatalError("Failed to open dataset (datasetName)")
}

let data = dataset[1...3, 2...5]

Supported types are: Double, Float, Int and String.

Latest podspec

{
    "name": "HDF5Kit",
    "version": "0.3.0",
    "summary": "Swift wrapper for HDF5",
    "homepage": "https://github.com/aleph7/HDF5Kit",
    "license": "MIT",
    "authors": {
        "Alejandro Isaza": "[email protected]"
    },
    "platforms": {
        "osx": "10.10",
        "ios": "8.0"
    },
    "swift_version": "4.0",
    "source": {
        "git": "https://github.com/aleph7/HDF5Kit.git",
        "tag": "0.3.0"
    },
    "exclude_files": "dist/src/H5detect.c",
    "source_files": [
        "Source",
        "dist/src/*.{c,h}",
        "dist/src/H5detect.c"
    ],
    "public_header_files": [
        "dist/src/*public.h",
        "dist/src/H5Epubgen.h",
        "dist/src/H5api_adpt.h",
        "dist/src/H5version.h",
        "dist/src/H5pubconf.h"
    ],
    "private_header_files": "dist/src/*private.h",
    "libraries": "z"
}

Pin It on Pinterest

Share This