Python读取mat文件,并转为csv文件的实例
作者:Luisa_M 时间:2023-01-01 11:03:54
初学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)
来源:https://blog.csdn.net/zebralxr/article/details/78254192
标签:Python,mat,csv
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
同时安装sql2000和sql2005,经验点滴
2008-03-04 17:56:00
如何使数据库中取出的数据保持原有格式
2008-11-27 16:16:00
Python获取航线信息并且制作成图的讲解
2023-08-28 18:18:56
![](https://img.aspxhome.com/file/2023/6/61986_0s.png)
Python tkinter实现的图片移动碰撞动画效果【附源码下载】
2022-03-19 03:05:26
![](https://img.aspxhome.com/file/2023/6/72786_0s.gif)
Python程序中的观察者模式结构编写示例
2022-08-04 22:12:11
![](https://img.aspxhome.com/file/2023/3/66823_0s.png)
python集合比较(交集,并集,差集)方法详解
2023-09-30 22:11:13
JavaScript的兼容性与调试技巧
2023-07-14 07:56:28
![](https://img.aspxhome.com/file/2023/9/55929_0s.jpg)
详解Python中的type和object
2021-03-25 13:00:58
![](https://img.aspxhome.com/file/2023/1/67921_0s.png)
能否用显示/隐藏层来控制FLASH播放与停止
2008-10-27 14:08:00
SQL语句执行顺序图文介绍
2023-07-04 22:59:27
![](https://img.aspxhome.com/file/UploadPic/201211/30/20121130203549375s.png)
Python模拟登录和登录跳转的参考示例
2023-07-29 07:09:47
PHP实现的简单排列组合算法应用示例
2023-11-18 16:28:40
php网络安全中命令执行漏洞的产生及本质探究
2023-05-30 05:34:31
jQuery.animate简单分析
2010-06-26 12:45:00
oracle数据库tns配置方法详解
2023-07-20 16:14:10
![](https://img.aspxhome.com/file/2023/7/63367_0s.png)
python中join与os.path.join()函数实例详解
2023-08-23 19:20:51
![](https://img.aspxhome.com/file/2023/6/62866_0s.png)
如何通过PHP实现Des加密算法代码实例
2023-10-08 09:41:55
教你如何使用php session
2023-11-15 06:28:01
配置高可用性的MySQL服务器负载均衡群集
2009-01-04 12:43:00
php使用pthreads v3多线程实现抓取新浪新闻信息操作示例
2023-10-12 19:21:46
![](https://img.aspxhome.com/file/2023/9/55619_0s.png)