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