From: Magnus Hagander Date: Thu, 30 Jan 2020 11:11:49 +0000 (+0100) Subject: Implement the new API for bank file uploads X-Git-Url: http://git.postgresql.org/gitweb/edit?a=commitdiff_plain;h=c075c2253caffa0841a617aea188c9104e906d6b;p=pgeu-web.git Implement the new API for bank file uploads In particular, this moves the decoding of the character set into this implementation, and update that one to use iso-8859-1 which is what CM uses. --- diff --git a/code/pgeusite/cmutuel/util.py b/code/pgeusite/cmutuel/util.py index 0f5a545..8b58018 100644 --- a/code/pgeusite/cmutuel/util.py +++ b/code/pgeusite/cmutuel/util.py @@ -56,7 +56,8 @@ Download a reasonable range of transactions, typically with a few days overlap. 'invoice': invoice, }) - def parse_uploaded_file(self, contents): + def parse_uploaded_file(self, f): + contents = f.read().decode('iso-8859-1') reader = csv.reader(contents.splitlines(), delimiter=';') # Write everything to the database @@ -116,4 +117,4 @@ Download a reasonable range of transactions, typically with a few days overlap. # Re-raise but including the full row information raise Exception("Exception '{0}' when parsing row {1}".format(e, row)) - return (numrows, numtrans, numpending) + return (contents, numrows, numtrans, numpending)