2016-02-01 40 views
0

我想用Python讀入.dat和.atr文件;來自Physionet,these for example。我已經試過了標準的上下文管理器開啓方法:用Python打開.dat和.atr文件類型

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(我從這個數據集發表的研究中知道這一點)。任何想法如何閱讀這些數據?

+0

我建議你在深入瞭解這些鏈接:https://www.physionet.org/physiotools/wpg/wpg_toc.htm和https:// WWW .physionet.org/physiotools/WAG / – Tanner

回答

0

你可以嘗試打開它using numpy

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