diff --git a/ofx_processor/processors/lcl.py b/ofx_processor/processors/lcl.py index 58733b1..e5c4ac2 100644 --- a/ofx_processor/processors/lcl.py +++ b/ofx_processor/processors/lcl.py @@ -1,5 +1,6 @@ import sys from datetime import datetime +from operator import truediv import click import dateparser @@ -67,19 +68,27 @@ class LclProcessor(OfxBaseProcessor): click.secho("Couldn't find ofx file", fg="red") sys.exit(1) - if "Content-Type:" in data[0]: - with open(self.filename, "w") as temp_file: - temp_file.writelines(data[1:]) + new_lines = [line for line in data if is_valid_line(line)] + + with open(self.filename, "w") as temp_file: + temp_file.writelines(new_lines) ofx = super()._parse_file() - if "Content-Type:" in data[0]: - with open(self.filename, "w") as temp_file: - temp_file.writelines(data) + with open(self.filename, "w") as temp_file: + temp_file.writelines(data) return ofx +def is_valid_line(line): + if "Content-Type:" in line: + return False + if "MKTGINFO" in line: + return False + return True + + def main(filename, keep, download, send_method, push_to_ynab): """Import LCL bank statement (OFX file).""" if download: @@ -91,6 +100,7 @@ def main(filename, keep, download, send_method, push_to_ynab): ) filename = LclDownloader().download() processor = LclProcessor(filename) + processor.parse_file() if send_method: processor.send_reconciled_amount(send_method) if push_to_ynab: diff --git a/pyproject.toml b/pyproject.toml index 69dad15..6fcf186 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ofx-processor" -version = "4.5.1" +version = "4.5.2" description = "Personal ofx processor" readme = "README.md" authors = ["Gabriel Augendre "]