From aa3cc9c657ee34206d0e6f61fa6a786ec9adbca8 Mon Sep 17 00:00:00 2001 From: bitsofwinter Date: Fri, 13 Apr 2018 19:20:15 +0200 Subject: [PATCH] Support for UTF-8 encoded files with BOM (Byte Order Mark) --- taxdata.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/taxdata.py b/taxdata.py index a2ed0b1..0a34466 100644 --- a/taxdata.py +++ b/taxdata.py @@ -12,7 +12,7 @@ def __init__(self, namn, personnummer, postnummer, postort): @staticmethod def read_from(filename): - with open(filename, encoding="utf-8") as f: + with open(filename, encoding="utf-8-sig") as f: d = json.load(f) return PersonalDetails(d["namn"], d["personnummer"], d["postnummer"], d["postort"]) @@ -23,7 +23,7 @@ def __init__(self, fees): @staticmethod def read_from(filename): - with open(filename, encoding="utf-8") as f: + with open(filename, encoding="utf-8-sig") as f: d = json.load(f) return Fees(d["fees"]) @@ -49,7 +49,7 @@ def __init__(self, trades): @staticmethod def read_from(filename): - with open(filename, encoding='utf-8') as f: + with open(filename, encoding='utf-8-sig') as f: lines = [line for line in csv.reader(f, delimiter=',', quotechar='"')] def indices(col_name): @@ -108,7 +108,7 @@ def profit(self): @staticmethod def read_stock_tax_events_from(filename:str): - with open(filename, encoding="utf-8") as f: + with open(filename, encoding="utf-8-sig") as f: d = json.load(f) events = [] for event in d["trades"]: