From 855f9b652dea35d5d66f94e8c3d93c354b0484e3 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 31 May 2022 12:31:25 -0400 Subject: [PATCH] Handle Byte Order Mark (BOM) in CSVs --- memberPlumbing/MembershipWorks.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/memberPlumbing/MembershipWorks.py b/memberPlumbing/MembershipWorks.py index 2349103..02f928e 100644 --- a/memberPlumbing/MembershipWorks.py +++ b/memberPlumbing/MembershipWorks.py @@ -197,6 +197,10 @@ class MembershipWorks: ) if r.status_code != 200: raise MembershipWorksRemoteError("csv generation", r) + + if r.text[0] == "\ufeff": + r.encoding = r.encoding + "-sig" + return list(csv.DictReader(StringIO(r.text))) def get_transactions(self, start_date, end_date, json=False): @@ -221,6 +225,9 @@ class MembershipWorks: if json: return r.json() else: + if r.text[0] == "\ufeff": + r.encoding = r.encoding + "-sig" + return list(csv.DictReader(StringIO(r.text))) def get_all_members(self):