用Python打开.dat和.atr文件类型

2024-04-23 20:17:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用Python读入.dat和.atr文件;从physoninet,these for example。我尝试过标准的上下文管理器打开方法:

with open("path/to/files/101.dat", "rb") as f:
  for line in f: print f

但是我得到了一些无法解释的结果,比如D"D ?C?C?C!?C?C?C?C?C。这些行应该像3.0000000e-003 4.9950000e+000 4.3400000e+000(我从这个数据集发布的研究中知道这一点)。有什么办法我能读懂这些数据吗?在


Tags: 文件数据path方法管理器for标准example
2条回答

你可以试着打开它using ^{}

import numpy as np
myarray = np.fromfile("path/to/files/101.dat",dtype=float)

要读取.dat文件,请使用以下代码-

record = wfdb.rdrecord('../input/apneaecg/apnea-ecg/a01') 
wfdb.plot_wfdb(record, title='Record a01 from Physionet Apnea ECG') 
display(record.__dict__)

你需要安装wfdb库。 上面字典中的p_信号数组包含a01人的ECG值。在

相关问题 更多 >