I am trying to save contents of physiobank Normal Sinus Rhythm RR Interval Database into a numpy array but I keep getting an error:
Traceback (most recent call last):
File "AverageRRI.py", line 20, in <module>
averageArray = np.fromfile(file,dtype=float)
FileNotFoundError: [Errno 2] No such file or directory: 'nsr001.ecg'
but the file does exist in the directory.
import os
import numpy as np
for root, dirs, files in os.walk('normal-sinus-rhythm-rr-interval-database-1.0.0'):
for file in files:
if file.endswith(".ecg"):
print(file)
averageArray = np.fromfile(file,dtype=float)
print(averageArray)
When I add the pathname like:
averageArray = np.fromfile('normal-sinus-rhythm-rr-interval-database-1.0.0/nsr001.ecg',dtype=float)
print(averageArray)
It works.
Thanks so much!