Abh*_*nan 8 python matlab scipy
我正在使用python w/scipy包来读取MatLab文件.
然而,它需要太长时间和崩溃.
该数据集的大小约为50〜MB
有没有更好的方法来读取数据并形成边缘列表?
我的python代码
import scipy.io as io
data=io.loadmat('realitymining.mat')
print data
Run Code Online (Sandbox Code Playgroud)
我解压后可以加载。但它正在拉伸记忆。
当我尝试加载它时,octave我得到:
octave:1> load realitymining.mat
error: memory exhausted or requested size too large for range of Octave's index type -- trying to return to prompt
Run Code Online (Sandbox Code Playgroud)
在Ipython中
In [10]: data.keys()
Out[10]: ['network', 's', '__version__', '__header__', '__globals__']
In [14]: data['__header__']
Out[14]: 'MATLAB 5.0 MAT-file, Platform: MACI, Created on: Tue Sep 29 20:13:23 2009'
In [15]: data['s'].shape
Out[15]: (1, 106)
In [17]: data['s'].dtype
Out[17]: dtype([('comm', 'O'), ('charge', 'O'), ('active', 'O'), ('logtimes', 'O'),...
('my_intros', 'O'), ('home_nights', 'O'), ('comm_local', 'O'), ('data_mat', 'O')])
# 58 fields
In [24]: data['s']['comm'][0,1].shape
Out[24]: (1, 30)
In [31]: data['s']['comm'][0,1][0,1]
Out[31]: ([[732338.8737731482]], [[355]], [[-1]], [u'Packet Data'], [u'Outgoing'],
[[40]], [[nan]])
In [33]: data['s']['comm'][0,1]['date']
Out[33]:
array([[array([[ 732338.86915509]]), array([[ 732338.87377315]]),
...
array([[ 732340.48579861]]), array([[ 732340.52778935]])]], dtype=object)
Run Code Online (Sandbox Code Playgroud)
看看碎片。只是尝试print data或print data['s']花费太长时间。显然它的结构太大而无法快速格式化。
为了实际获取这一数据,我建议在 Python 或 Matlab 中加载一次,然后将有用的部分保存到一个或多个文件中。