Add account amount after each transaction
This commit is contained in:
parent
5f439c0e61
commit
02625cc71b
@ -34,21 +34,25 @@ for folder in os.listdir():
|
|||||||
for file in os.listdir(folder):
|
for file in os.listdir(folder):
|
||||||
#folder = '2022'
|
#folder = '2022'
|
||||||
#file = '20220321.pdf'
|
#file = '20220321.pdf'
|
||||||
print(folder, file)
|
|
||||||
filePath = f'{folder}/{file}'
|
filePath = f'{folder}/{file}'
|
||||||
|
print(filePath)
|
||||||
content = getTextFromPdf(filePath)
|
content = getTextFromPdf(filePath)
|
||||||
lines = content.splitlines()
|
lines = content.splitlines()
|
||||||
started = False
|
started = False
|
||||||
firstPage = True
|
firstPage = True
|
||||||
payment = []
|
|
||||||
initialAmount = None
|
initialAmount = None
|
||||||
|
currentAmount = None
|
||||||
|
date = None
|
||||||
|
comment = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if not started:
|
if not started:
|
||||||
# We are interested in the content after this line:
|
# We are interested in the content after this line:
|
||||||
if soldeCrediteurAuRegex.match(line) != None or (line.startswith('Date Nature des opérations Valeur Débit Crédit') and not firstPage):
|
if soldeCrediteurAuRegex.match(line) != None or (line.startswith('Date Nature des opérations Valeur Débit Crédit') and not firstPage):
|
||||||
if soldeCrediteurAuRegex.match(line):
|
if soldeCrediteurAuRegex.match(line):
|
||||||
initialAmount = float(soldeCrediteurAuRegex.sub('', line).replace(',', '.').replace(' ', ''))
|
initialAmount = float(soldeCrediteurAuRegex.sub('', line).replace(',', '.').replace(' ', ''))
|
||||||
print(initialAmount)
|
currentAmount = initialAmount
|
||||||
|
print('Initial amount', initialAmount)
|
||||||
|
print()
|
||||||
started = True
|
started = True
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@ -61,8 +65,16 @@ for folder in os.listdir():
|
|||||||
elif line.startswith('TOTAL DES OPERATIONS'):
|
elif line.startswith('TOTAL DES OPERATIONS'):
|
||||||
break
|
break
|
||||||
if firstLineOfPaymentRegex.match(line) != None:
|
if firstLineOfPaymentRegex.match(line) != None:
|
||||||
|
if date != None:
|
||||||
|
print(date, valeur, amount, currentAmount)
|
||||||
|
print("\n".join(comment))
|
||||||
print()
|
print()
|
||||||
print(line)
|
date, valeur, amount = line.split()
|
||||||
|
amount = float(amount.replace(',', '.'))
|
||||||
|
currentAmount -= amount
|
||||||
|
comment = []
|
||||||
|
else:
|
||||||
|
comment += [line]
|
||||||
break
|
break
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user