reubano / csv2ofx

A Python library and command line tool for converting csv to ofx and qif files
MIT License
199 stars 113 forks source link

Show nice error message when file is missing a mapping field #8

Closed reubano closed 8 years ago

reubano commented 8 years ago

Currently it crashes

Traceback (most recent call last):
  File "/Users/reubano/Library/Python/2.7/bin/csv2ofx", line 20, in <module>
    run()
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/csv2ofx/main.py", line 141, in run
    write(args.dest, IterStringIO(content), **kwargs)
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/tabutils/io.py", line 691, in write
    return _write(filepath, content, **kwargs)
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/tabutils/io.py", line 679, in _write
    for c in ft.chunk(content, chunksize):
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/tabutils/fntools.py", line 248, in <genexpr>
    generator = (content.read(chunksize) for _ in it.count())
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/tabutils/io.py", line 110, in read
    return self._read(self.iter, n)
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/tabutils/io.py", line 103, in _read
    return ft.byte(it.islice(iterable, n)) if n else ft.byte(iterable)
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/tabutils/fntools.py", line 183, in byte
    tupled = tuple(content) if hasattr(content, 'next') else content
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/tabutils/io.py", line 96, in <genexpr>
    return (s.encode(ENCODING) for s in iterable)
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/csv2ofx/qif.py", line 233, in gen_body
    for gd in data:
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/csv2ofx/utils.py", line 130, in gen_data
    for group, main_pos, sorted_trxns in groups:
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/csv2ofx/__init__.py", line 238, in clean_trxns
    for group, trxns in groups:
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/csv2ofx/__init__.py", line 224, in gen_trxns
    for group, transactions in groups:
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/csv2ofx/qif.py", line 260, in gen_groups
    for group in utils.group_transactions(chnk, keyfunc):
  File "/Users/reubano/Library/Python/2.7/lib/python/site-packages/csv2ofx/utils.py", line 123, in group_transactions
    sorted_transactions = sorted(transactions, key=keyfunc)
KeyError: 'Account'