Skip to content

Commit

Permalink
Ensure the CSV file is always closed correctly
Browse files Browse the repository at this point in the history
Since currently this is not possible when using a file as parameter (see
kedder/ofxstatement#71) the easiest workaround
is to simply pass the file content to the parser. The csv.reader() takes
any iterable (such as a list of lines, as in this case) as input.
  • Loading branch information
omarkohl committed Mar 14, 2018
1 parent 9c887d5 commit 433a969
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ofxstatement/plugins/germany_1822direkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
class FrankfurterSparkasse1822Plugin(Plugin):
def get_parser(self, filename):
encoding = self.settings.get('charset', 'iso-8859-1')
f = open(filename, 'r', encoding=encoding)
parser = FrankfurterSparkasse1822Parser(f)
with open(filename, 'r', encoding=encoding) as f:
lines = f.readlines()
parser = FrankfurterSparkasse1822Parser(lines)
parser.statement.account_id = self.settings['account']
parser.statement.bank_id = self.settings.get('bank', '50050201')
parser.statement.currency = self.settings.get('currency', 'EUR')
Expand Down

0 comments on commit 433a969

Please sign in to comment.