3

I'm trying to read in .dat and .atr files with Python; from Physionet, these for example. I've tried the standard context manager opening method:

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

But I get uninterpretable results like D"D ?C?C?C!?C?C?C?C?C for the lines. These lines should be like 3.0000000e-003 4.9950000e+000 4.3400000e+000 (I know this from published studies with this dataset). Any ideas how I can read in this data?

1

3 Answers 3

6

You can try to open it using numpy

import numpy as np
myarray = np.fromfile("path/to/files/101.dat",dtype=float)
Sign up to request clarification or add additional context in comments.

1 Comment

This can open file, but not in correct way
3

To read a .dat file use the following code-

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

You need to have wfdb library installed for that. The p_signal array in the above dictionary contains the ECG values for a01 person.

Comments

0

I know this is old, but this has worked for me:

data = np.genfromtxt('data.dat' , dtype=None, names=True, delimiter='\t')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.