Skip to content

Commit

Permalink
Support for UTF-8 encoded files with BOM (Byte Order Mark)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsofwinter committed Apr 13, 2018
1 parent a79be60 commit aa3cc9c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions taxdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -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"])

Expand All @@ -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):
Expand Down Expand Up @@ -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"]:
Expand Down

0 comments on commit aa3cc9c

Please sign in to comment.