Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit a5a9466

Browse files
committed
Fixed an issue in Python 3 when using numpy.genfromtxt in storage.load_txt.
1 parent f8b66cf commit a5a9466

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

biosppy/storage.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,16 @@ def load_txt(path):
387387
# normalize path
388388
path = utils.normpath(path)
389389

390-
with open(path, 'r') as fid:
390+
with open(path, 'rb') as fid:
391391
lines = fid.readlines()
392392

393393
# extract header
394394
mdata_tmp = {}
395395
fields = ['Sampling Rate', 'Resolution', 'Date', 'Data Type', 'Labels']
396396
values = []
397397
for item in lines:
398-
if '#' in item:
398+
if b'#' in item:
399+
item = item.decode('utf-8')
399400
# parse comment
400401
for f in fields:
401402
if f in item:
@@ -432,7 +433,7 @@ def load_txt(path):
432433
pass
433434

434435
# load array
435-
data = np.genfromtxt(values, dtype=dtype, delimiter='\t')
436+
data = np.genfromtxt(values, dtype=dtype, delimiter=b'\t')
436437

437438
return data, mdata
438439

0 commit comments

Comments
 (0)