diff --git a/setup.cfg b/setup.cfg index ae22d85..a854cae 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = dcmReader -version = 0.4.0 +version = 0.4.1 author = Dominic Kuschmierz author_email = dominic@kuschmierz.org description = Parser for the DCM (Data Conservation format) format used by e.g. Vector, ETAS,... diff --git a/src/dcmReader/dcm_reader.py b/src/dcmReader/dcm_reader.py index 8dfeac4..3c1f44c 100644 --- a/src/dcmReader/dcm_reader.py +++ b/src/dcmReader/dcm_reader.py @@ -103,7 +103,7 @@ def convert_value(value): except ValueError as err: raise ValueError(f"Cannot convert {value} from string to number.") from err - def write(self, file) -> None: + def write(self, file, file_encoding="utf-8") -> None: """Writes the current DCM object to a dcm file Args: @@ -112,10 +112,10 @@ def write(self, file) -> None: if not file.endswith(".dcm"): file += ".dcm" - with open(file, "w", encoding="utf-8") as dcm_file: + with open(file, "w", encoding=file_encoding) as dcm_file: dcm_file.writelines(str(self)) - def read(self, file) -> None: + def read(self, file, file_encoding="utf-8") -> None: """Reads and processes the given file. Args: @@ -125,7 +125,7 @@ def read(self, file) -> None: comment_qualifier = ("!", "*", ".") - with open(file, "r", encoding="utf-8") as dcm_file: + with open(file, "r", encoding=file_encoding) as dcm_file: for line in dcm_file: # Remove whitespaces line = line.strip()