Changeset - b33c83af0a0f
[Not reviewed]
0 2 0
Brett Smith - 6 years ago 2018-06-20 19:59:56
brettcsmith@brettcsmith.org
importers: Catch and handle CSV parse errors in can_import.

import2ledger bailed on one of these exceptions when trying to import
a recent XLS file that had a null byte on a line.
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
import2ledger/importers/_csv.py
Show inline comments
...
 
@@ -65,4 +65,8 @@ class CSVImporterBase:
 
    def can_import(cls, input_file):
 
        _, fields = cls._read_header(input_file)
 
        return cls._NEEDED_KEYS.issubset(fields or ())
 
        try:
 
            _, fields = cls._read_header(input_file)
 
        except csv.Error:
 
            return False
 
        else:
 
            return cls._NEEDED_KEYS.issubset(fields or ())
 

	
setup.py
Show inline comments
...
 
@@ -32,3 +32,3 @@ setup(
 
    description="Import different sources of financial data to Ledger",
 
    version='0.3',
 
    version='0.4',
 
    author='Brett Smith',
0 comments (0 inline, 0 general)