直接从python中的在线存档导入.edf文件

时间:2017-11-01 10:45:52

标签: python import european-data-format

使用pyedflib导入edf文件,是否可以直接从其源中导入数据集?或者是否始终需要下载数据并在本地导入?

例如,我想这样做:

pyedflib.EdfReader("https://www.physionet.org/pn6/chbmit/chb02/chb02_02.edf")

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-64-d123ce671a2f> in <module>()
----> 1 pyedflib.EdfReader("https://www.physionet.org/pn6/chbmit/chb02/chb02_02.edf")

pyedflib/_extensions/_pyedflib.pyx in pyedflib._extensions._pyedflib.CyEdfReader.__init__()

pyedflib/_extensions/_pyedflib.pyx in pyedflib._extensions._pyedflib.CyEdfReader.open()

pyedflib/_extensions/_pyedflib.pyx in pyedflib._extensions._pyedflib.CyEdfReader.check_open_ok()

IOError: can not open file, no such file or directory

1 个答案:

答案 0 :(得分:0)

在GitHub页面上收到的答案

import pyedflib
import os
url = "https://www.physionet.org/pn6/chbmit/chb01/chb01_01.edf"
filename = "./chb.edf"
try:
    from urllib import urlretrieve # Python 2

except ImportError:
    from urllib.request import urlretrieve # Python 3

urlretrieve(url,filename)
pyedflib.EdfReader(filename)
os.remove(filename)

https://github.com/holgern/pyedflib/issues/22#issuecomment-341649760