Commit 0ee21702 authored by Manuel Günther's avatar Manuel Günther

Solved Python3 issue with csv reading from bytes

parent 0c19f066
...@@ -9,6 +9,7 @@ import numpy ...@@ -9,6 +9,7 @@ import numpy
import csv import csv
import tarfile import tarfile
import os import os
import sys
import logging import logging
logger = logging.getLogger('bob.measure') logger = logging.getLogger('bob.measure')
...@@ -93,7 +94,12 @@ def four_column(filename): ...@@ -93,7 +94,12 @@ def four_column(filename):
""" """
reader = csv.reader(open_file(filename, mode='rb'), delimiter=' ') opened = open_file(filename, 'rb')
if sys.version_info.major > 2:
import io
opened = io.TextIOWrapper(opened, newline="")
reader = csv.reader(opened, delimiter=' ')
for splits in reader: for splits in reader:
splits[-1] = float(splits[-1]) splits[-1] = float(splits[-1])
yield splits yield splits
...@@ -214,7 +220,12 @@ def five_column(filename): ...@@ -214,7 +220,12 @@ def five_column(filename):
""" """
reader = csv.reader(open_file(filename, mode='rb'), delimiter=' ') opened = open_file(filename, 'rb')
if sys.version_info.major > 2:
import io
opened = io.TextIOWrapper(opened, newline="")
reader = csv.reader(opened, delimiter=' ')
for splits in reader: for splits in reader:
splits[-1] = float(splits[-1]) splits[-1] = float(splits[-1])
yield splits yield splits
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment