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(',', '.'))