Catch non parsable dates
authorAndreas Bilke <andreas@bilke.org>
Sun, 19 Nov 2017 17:02:20 +0000 (18:02 +0100)
committerAndreas Bilke <andreas@bilke.org>
Sun, 19 Nov 2017 17:02:20 +0000 (18:02 +0100)
banking/ingdiba2homebank.py

index 5038a89..265dce8 100755 (executable)
@@ -15,7 +15,11 @@ if __name__ == "__main__":
 
     for line in csvfile:
         fields = line.strip().split(";")
-        date = datetime.strptime(fields[2], "%d.%m.%Y")
+        try:
+            date = datetime.strptime(fields[2], "%d.%m.%Y")
+        except ValueError as e:
+            print(("Cannot convert line\n{}\n".format(line)), file=sys.stderr)
+            continue
 
         if fields[4] == "0,00":
             amount = fields[5]