isaacharrisholt / quiffen

Quiffen is a Python package for parsing QIF (Quicken Interchange Format) files.
MIT License
33 stars 28 forks source link

Bug fix for transaction parsing enums with trailing whitespace. #54

Closed sotoodaa-ucb closed 1 year ago

sotoodaa-ucb commented 1 year ago

For some unknown reason, my QIF file seems to append a whitespace after the Bank header of the transaction resulting in the following error.

  File "C:\Users\Apex\Desktop\Quicken\run.py", line 3, in <module>
    qif = Qif.parse('quicken.qif')
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Apex\AppData\Local\Programs\Python\Python311\Lib\site-packages\quiffen\core\qif.py", line 275, in parse
    AccountType(header_line.split(":")[1]),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Apex\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 717, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Apex\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1133, in __new__
    raise ve_exc
ValueError: 'Bank ' is not a valid AccountType

I was able to resolve this issue by stripping whitespace.

isaacharrisholt commented 1 year ago

Thanks for doing this!