forked from gerasiov/ofxstatement-seb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.py
executable file
·37 lines (26 loc) · 859 Bytes
/
convert.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os.path
import click
import logging
from ofxstatement.ofx import OfxWriter
from ofxstatement.plugins import seb
@click.command()
@click.argument('path')
@click.option('--debug', is_flag=True, default=False)
def convert(path, debug):
"""Parse and print transactions from SEB Export.xlsx file."""
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(message)s')
root, ext = os.path.splitext(path)
output_file = root + '.ofx'
parser = seb.SebPlugin(ui=None, settings=None).get_parser(path)
statement = parser.parse()
if debug:
for line in statement.lines:
print(line)
return
with open(output_file, 'w') as out:
writer = OfxWriter(statement)
out.write(writer.toxml())
if __name__ == '__main__':
convert()