source: fact/tools/pyscripts/sandbox/dneise/h5py/test.py@ 13449

Last change on this file since 13449 was 13445, checked in by neise, 12 years ago
simple test
File size: 709 bytes
Line 
1#!/usr/bin/python -tti
2
3print 'creating a file and writing some data to it'
4
5import h5py
6f = h5py.File('myfile.h5', 'w')
7dset = f.create_dataset('test', (100,100,100), 'i')
8dset[...] = 42
9f.close()
10
11del f
12del dset
13
14print 'file is now closed and all variables are deleted ...'
15# ----------------------------------------------------------------------------
16
17print 'reopening file for read access -- as variable f'
18
19f = h5py.File('myfile.h5', 'r')
20
21print 'type f.items() to look at its contents,'
22print 'retrieve the contents, as you would with a dict'
23print 'e.g. f[<name of item>]'
24
25print 'you can even access only part of the contents'
26print 'use slicing for this:'
27print 'e.g. f[<name of item>][23,10:20]'
28
Note: See TracBrowser for help on using the repository browser.