由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
_Python版 - 例子:把数据存入HDF5文件后用Matlab读取
相关主题
有matplotlib或numpy/scipy的同学帮我试试tar出来的文件的错容性怎么样?
google app engine 里 加载 numpygoogle sitemap能随便加吗?
查看numpy使用的数学库的信息也问个MatLab问题
solve integral eq. embeeded with another integral eq. (转载)估计干这个活SSD能快很多
ploting 3D surface in python (转载)How to creat .tar.gz?
error draw map from shape file Python 3.2 basemap (转载)[转载] Why gzip, compress won't work for RM file?
推荐Anaconda作为Numerical Analysis的Python集成环境how to compress several file under unix
A good way to compress client side data?请教怎样使用tar压文件
相关话题的讨论汇总
话题: data话题: hdf5话题: john话题: mary话题: testdata
1 (共1页)
p**z
发帖数: 65
1
不把笔记翻译成中文了,就直接贴了。
Example Python code below for creating the HDF5 file. Note uncompressed or '
gzip' compression type can be understood by both Matlab and HDFView.
from __future__ import division, print_function
import h5py
import numpy as np
data = np.array([('John', 35, 160.5), ('Mary', 20, 150)], dtype= [('Name', '
a10'), ('Age' ,'i'), ('Weight', 'f')])
##alternative:
#data = np.array([('John', 35, 160.5), ('Mary', 20, 150)], dtype = {'names':
['Name','Age','Weight'], 'formats':['a10','i','f']})
f = h5py.File(r'C:hdf5test.h5', 'w')
f.create_dataset('testdata', data = data, compression = 'gzip')
# f['testdata'] = data # alternative for uncompressed
f.close()
print('Data saved to HDF5 file.n')
f = h5py.File(r'C:hdf5test.h5', 'r')
rddata = f['testdata']
print('Data read-back:')
print(rddata[:])
Result:
Data saved to HDF5 file.
Data read-back:
[('John', 35, 160.5) ('Mary', 20, 150.0)]
>>>
Viewing test.h5 in HDFView:
Matlab code for reading the file created above:
clc; clear all;
fn = 'C:hdf5test.h5';
data = hdf5read(fn, 'testdata');
fprintf('Data read back from HDF5 file:nn')
for nrecord = 1:2
row = data(nrecord).Data;
fprintf('%st%dt%fn', row{1}.Data, row{2}, row{3});
end
Result:
Data read back from HDF5 file:
John 35 160.500000
Mary 20 150.000000
>>
1 (共1页)
相关主题
请教怎样使用tar压文件ploting 3D surface in python (转载)
*.ps.gz??error draw map from shape file Python 3.2 basemap (转载)
How to gzip a directory directly ?推荐Anaconda作为Numerical Analysis的Python集成环境
How to save variables in file in MATLABA good way to compress client side data?
有matplotlib或numpy/scipy的同学帮我试试tar出来的文件的错容性怎么样?
google app engine 里 加载 numpygoogle sitemap能随便加吗?
查看numpy使用的数学库的信息也问个MatLab问题
solve integral eq. embeeded with another integral eq. (转载)估计干这个活SSD能快很多
相关话题的讨论汇总
话题: data话题: hdf5话题: john话题: mary话题: testdata