Skip to content
Snippets Groups Projects
Commit d4557887 authored by Florian Obersteiner's avatar Florian Obersteiner
Browse files

removed try/except from readHeader

parent 136c60b0
Branches
Tags
1 merge request!6code refactor
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
......@@ -461,20 +461,12 @@ class Dataset:
dmp = [word.strip(" ") for word in dmp.split(self.splitChar)]
return dmp
if self.inputFhandle.closed:
self.inputFhandle = open(self.inputFhandle.name, encoding='utf-8')
if self.inputFhandle:
if self.inputFhandle.closed:
self.inputFhandle = open(self.inputFhandle.name, encoding='utf-8')
# TODO: refactor following try/except statement
# this one is challenging since we need an "unpopulated" file pointer if no file was specified :)
try:
f = FilehandleWithLinecounter(self.inputFhandle, splitChar)
self._readHeader(f)
del f
except:
a = 1
finally:
self.inputFhandle.close()
def _readHeader(self, f):
......@@ -923,6 +915,8 @@ class Dataset:
self.defineMode = True
self.inputFhandle = None
# read data if f is not None
if f is not None:
if isinstance(f, (str, pathlib.Path)):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment