From 9472be10f15d185b85b34a63117f4d06cd1462c4 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Mon, 18 Dec 2017 17:38:55 -0500 Subject: [PATCH] main: Open files with errors='replace'. Stripe payment CSVs have apparently random encoding, and no way what to tell what they're using beyond chardet. The better way to fix this is following the existing to-do item, opening files in binary mode and creating an importer base class to provide text wrapping. This would let each importer be as strict as possible. --- import2ledger/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/import2ledger/__main__.py b/import2ledger/__main__.py index dc7f5b9..7520fd5 100644 --- a/import2ledger/__main__.py +++ b/import2ledger/__main__.py @@ -51,7 +51,7 @@ class FileImporter: def import_path(self, in_path): if in_path is None: raise errors.UserInputFileError("only seekable files are supported", '') - with in_path.open() as in_file: + with in_path.open(errors='replace') as in_file: if not in_file.seekable(): raise errors.UserInputFileError("only seekable files are supported", in_path) return self.import_file(in_file)