Python读取mat文件,并转为csv文件的实例
初学Python,遇到需要将mat文件转为csv文件,看了很多博客,最后找到了解决办法,代码如下:
#方法1 from pandas import Series,DataFrame import pandas as pd import numpy as np import h5py datapath = 'E:/workspacelxr/contem/data.mat' file = h5py.File(datapath,'r') file.keys() def Print(name):print(name) data = file['data'][:] dfdata = pd.DataFrame(data) datapath1 = 'E:/workspacelxr/contem/data.txt' dfdata.to_csv(datapath1,index=False)
#方法2 import pandas as pd import scipy from scipy import io features_struct = scipy.io.loadmat('E:/workspacelxr/contem/data.mat') features = features_struct['data'] dfdata = pd.DataFrame(features) datapath1 = 'E:/workspacelxr/contem/data.txt' dfdata.to_csv(datapath1, index=False)
相关推荐
digwtx 2020-09-14
FlySky 2020-11-02
逍遥友 2020-10-26
taiyangshenniao 2020-10-05
flycony 2020-09-23
jacktangj 2020-09-18
YENCSDN 2020-09-15
lsjweiyi 2020-09-14
拾毅者 2020-09-14
zlxcsdn 2020-09-13
weiiron 2020-08-17
amazingbo 2020-08-16
郗瑞强 2020-08-16
lispython 2020-08-16
fengling 2020-08-15
xiesheng 2020-08-02
葫芦小金刚 2020-07-28
StevenSun空间 2020-07-26