-
Notifications
You must be signed in to change notification settings - Fork 27
/
main.py
42 lines (29 loc) · 1.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python3
import argparse
from revolut import RevolutCsvReader
from mt940 import Mt940Writer
def main():
parser = argparse.ArgumentParser(
prog='oddity-revolut-to-mt940',
description='Convert Revolut CSV-files to MT940 format.')
parser.add_argument('--in',
dest='input_file',
help='path to Revolut csv-file',
required=True)
parser.add_argument('--account-iban',
dest='account_iban',
help='Revolut account IBAN',
required=True)
parser.add_argument('--out',
dest='output_file',
help='path to MT940 output path',
required=True)
args = parser.parse_args()
reader = RevolutCsvReader(args.input_file)
transactions = reader.get_all_transactions()
with Mt940Writer(args.output_file, args.account_iban, transactions[0].datetime.strftime('%Y-%m')) as writer:
for transaction in transactions:
writer.write_transaction(transaction)
print('Wrote {} transactions to file: {}.'.format(len(transactions), args.output_file))
if __name__ == "__main__":
main()