Last active
December 4, 2020 10:07
-
-
Save erget/d9a1cee00052f400589cc5db78884f49 to your computer and use it in GitHub Desktop.
Plot bank account balance in CSV-MT940 format based on a starting balance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Plot bank account balance in CSV-MT940 format based on a starting balance.""" | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import argparse | |
import os | |
parser = argparse.ArgumentParser(description=__doc__) | |
parser.add_argument("filename", help="File to parse") | |
parser.add_argument("start_balance", help="Balance at beginning of file", | |
type=float) | |
args = parser.parse_args() | |
verlauf = pd.read_csv(os.path.expanduser(args.filename), sep=";", | |
encoding="ISO-8859-1", decimal=",") | |
verlauf["Date"] = pd.to_datetime(verlauf.Buchungstag, | |
format="%d.%m.%y") | |
verlauf = verlauf.reindex(index=verlauf.index[::-1]) | |
verlauf["Kumulativer Umsat"] = verlauf.Betrag.cumsum() | |
verlauf["Kontostand"] = verlauf["Kumulativer Umsat"] + args.start_balance | |
verlauf.index = verlauf.Date | |
verlauf.resample("D").max().interpolate().Kontostand.plot() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment