Specify compte_de_cheques/
This commit is contained in:
parent
f090374caf
commit
ee6e850174
@ -9,7 +9,7 @@ import matplotlib.pyplot as plt
|
|||||||
import matplotlib.ticker as ticker
|
import matplotlib.ticker as ticker
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
path = f'/home/benjamin/Desktop/bens_folder/bazaar/documents/bnp/bank_statements/'
|
path = f'/home/benjamin/Desktop/bens_folder/bazaar/documents/bnp/bank_statements/compte_de_cheques/'
|
||||||
|
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
@ -45,12 +45,11 @@ firstDatetime = None
|
|||||||
lastDatetime = None
|
lastDatetime = None
|
||||||
for folder in sorted(os.listdir()):
|
for folder in sorted(os.listdir()):
|
||||||
for file in sorted(os.listdir(folder)):
|
for file in sorted(os.listdir(folder)):
|
||||||
#folder = '2022'
|
|
||||||
#file = '20220321.pdf'
|
|
||||||
filePath = f'{folder}/{file}'
|
filePath = f'{folder}/{file}'
|
||||||
print(filePath)
|
print(filePath)
|
||||||
|
currentDatetime = getDatetime(file)
|
||||||
if firstDatetime is None:
|
if firstDatetime is None:
|
||||||
firstDatetime = file
|
firstDatetime = currentDatetime
|
||||||
content = getTextFromPdf(filePath)
|
content = getTextFromPdf(filePath)
|
||||||
lines = content.splitlines()
|
lines = content.splitlines()
|
||||||
started = False
|
started = False
|
||||||
@ -86,7 +85,6 @@ for folder in sorted(os.listdir()):
|
|||||||
totalMonthlyDebits += [totalMonthlyDebit]
|
totalMonthlyDebits += [totalMonthlyDebit]
|
||||||
totalMonthlyCredits += [totalMonthlyCredit]
|
totalMonthlyCredits += [totalMonthlyCredit]
|
||||||
totalMonthlyDifference = totalMonthlyCredit - totalMonthlyDebit
|
totalMonthlyDifference = totalMonthlyCredit - totalMonthlyDebit
|
||||||
#print(totalMonthlyDifference)
|
|
||||||
totalMonthlyDifferences += [totalMonthlyDifference]
|
totalMonthlyDifferences += [totalMonthlyDifference]
|
||||||
break
|
break
|
||||||
if firstLineOfPaymentRegex.match(line) is not None:
|
if firstLineOfPaymentRegex.match(line) is not None:
|
||||||
@ -102,7 +100,7 @@ for folder in sorted(os.listdir()):
|
|||||||
comment += [line]
|
comment += [line]
|
||||||
#break
|
#break
|
||||||
#break
|
#break
|
||||||
lastDatetime = file
|
lastDatetime = getDatetime(file)
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
plt.title('Monthly debits and credits')
|
plt.title('Monthly debits and credits')
|
||||||
@ -110,15 +108,14 @@ plt.xlabel('Date')
|
|||||||
plt.ylabel('€')
|
plt.ylabel('€')
|
||||||
ALPHA = 0.5
|
ALPHA = 0.5
|
||||||
|
|
||||||
def getMonthIndex(aDatetimeStr):
|
def getDatetime(aDatetimeStr):
|
||||||
aDatetime = datetime.strptime(aDatetimeStr, '%Y%m%d.pdf')
|
return datetime.strptime(aDatetimeStr, '%Y%m%d.pdf')
|
||||||
|
|
||||||
|
def getMonthIndex(aDatetime):
|
||||||
return aDatetime.year * 12 + aDatetime.month
|
return aDatetime.year * 12 + aDatetime.month
|
||||||
|
|
||||||
xTicks = range(getMonthIndex(firstDatetime), getMonthIndex(lastDatetime) + 1)
|
xTicks = range(getMonthIndex(firstDatetime), getMonthIndex(lastDatetime) + 1)
|
||||||
# sign does not seem respected for `totalMonthlyDifferences`.
|
# sign does not seem respected for `totalMonthlyDifferences`.
|
||||||
#print(totalMonthlyDifferences)
|
|
||||||
#print(f'{min(totalMonthlyDifferences)}')
|
|
||||||
#print(f'{max(totalMonthlyDifferences)}')
|
|
||||||
totalMonthlyAmountAndLabel = (
|
totalMonthlyAmountAndLabel = (
|
||||||
#(totalMonthlyDebits, 'Debit'),
|
#(totalMonthlyDebits, 'Debit'),
|
||||||
#(totalMonthlyCredits, 'Credit'),
|
#(totalMonthlyCredits, 'Credit'),
|
||||||
@ -129,7 +126,6 @@ for totalMonthlyAmount, totalMonthlyLabel in totalMonthlyAmountAndLabel:
|
|||||||
plt.bar(xTicks, totalMonthlyAmount, alpha = ALPHA, label = totalMonthlyLabel)
|
plt.bar(xTicks, totalMonthlyAmount, alpha = ALPHA, label = totalMonthlyLabel)
|
||||||
plt.legend()
|
plt.legend()
|
||||||
|
|
||||||
# Hides negative
|
|
||||||
#plt.yscale('symlog')
|
#plt.yscale('symlog')
|
||||||
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter('{x:,}'))
|
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter('{x:,}'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user