46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
import argparse
|
|
|
|
from mbank import MbankCsvReader
|
|
from mt940 import Mt940Writer
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
prog="oddity-mbank-to-mt940",
|
|
description="Convert mBank CSV-files to MT940 format.",
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--in", dest="input_file", help="path to Revolut csv-file", required=True
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--out", dest="output_file", help="path to MT940 output path", required=True
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
reader = MbankCsvReader(args.input_file)
|
|
|
|
print(reader.range)
|
|
with Mt940Writer(
|
|
args.output_file,
|
|
reader.iban,
|
|
reader.range,
|
|
reader.starting_balance,
|
|
reader.date_start,
|
|
) as writer:
|
|
transactions = reader.get_all_transactions()
|
|
for transaction in transactions:
|
|
writer.write_transaction(transaction)
|
|
|
|
print(
|
|
"Wrote {} transactions to file: {}.".format(
|
|
len(transactions), args.output_file
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|