PIA-Group/BioSPPy

Path to file not working on Windows

Arinelle opened this issue · 1 comments

When I run the following:
ecg_signal, ecg_mdata = storage.load_txt('D:\Data\bitalinoECG.txt')

I obtain this error:
OSError: [Errno 22] Invalid argument: 'D:\\Data\x08italinoECG.txt'

Apparently the string is not properly escaped.

Hi @Arinelle

I'm assuming you are working on Windows, where it is frequent to have problems with path handling within Python. Note that Windows uses the backslash (\) in paths, which is an escape character in Python strings (\b actually represents a backspace ASCII character).

To overcome this, use either raw string literals (does not escape backslashes):
ecg_signal, ecg_mdata = storage.load_txt(r'D:\Data\bitalinoECG.txt')
or escape the backslash:
ecg_signal, ecg_mdata = storage.load_txt('D:\\Data\\bitalinoECG.txt')