From 9ceaa935b7471f2ea376eff9eb0b6326f4a9c826 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Fri, 28 Jul 2023 14:54:53 +0200 Subject: [PATCH] Replace `"\n"` with `n` in Python scripts --- bnp_pdf_statement_parser.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bnp_pdf_statement_parser.py b/bnp_pdf_statement_parser.py index 80e4ee4..72bcfd8 100755 --- a/bnp_pdf_statement_parser.py +++ b/bnp_pdf_statement_parser.py @@ -2,7 +2,7 @@ # Depends on `pdftotext`. -import os, subprocess, shlex, re, config +import os, subprocess, re, config path = f'/home/benjamin/Desktop/bens_folder/bazaar/documents/bnp/RLV_CHQ_{config.RLV_CHQ}' @@ -20,11 +20,10 @@ Assuming file hierarchy like: ''' def execute(command): - return subprocess.check_output(command, shell = True).decode('utf-8') + return subprocess.check_output(command, shell).decode('utf-8') def getTextFromPdf(pdfPath): - pdfPath = shlex.quote(pdfPath) - return execute(f'pdftotext -raw {pdfPath} -') + return execute(['pdftotext', '-raw', pdfPath, '-') firstLineOfPaymentRegex = re.compile('\d{2}\.\d{2} \d{2}\.\d{2} \d+,\d{2}') endPageAfterTheFirstOneRegex = re.compile('P\. \d+/\d+') @@ -67,7 +66,7 @@ for folder in os.listdir(): if firstLineOfPaymentRegex.match(line) != None: if date != None: print(date, valeur, amount, currentAmount) - print("\n".join(comment)) + print('\n'.join(comment)) print() date, valeur, amount = line.split() amount = float(amount.replace(',', '.'))