Skip to content

Instantly share code, notes, and snippets.

@andrewgiessel
Last active January 7, 2020 18:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewgiessel/7515520 to your computer and use it in GitHub Desktop.
Save andrewgiessel/7515520 to your computer and use it in GitHub Desktop.
simple example to use pytables to save a numpy array
import tables
import numpy as np
# Store "all_data" in a chunked array...
# from: http://stackoverflow.com/questions/8843062/python-how-to-store-a-numpy-multidimensional-array-in-pytables
f = tables.openFile('all_data.hdf', 'w')
atom = tables.Atom.from_dtype(all_data.dtype)
filters = tables.Filters(complib='blosc', complevel=5)
ds = f.createCArray(f.root, 'all_data', atom, all_data.shape, filters=filters)
# save w/o compressive filter
#ds = f.createCArray(f.root, 'all_data', atom, all_data.shape)
ds[:] = all_data
f.close()
@jason-s
Copy link

jason-s commented Nov 15, 2018

shouldn't it be f.create_carray() not `createCArray()~?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment