New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codec error on import of QFX file #423

Closed
brownnrl opened this Issue Mar 5, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@brownnrl
Copy link
Contributor

brownnrl commented Mar 5, 2015

Ugh, was using QIF for import, but my credit card just went to QFX only. Get a codec error. Going to try to investigate myself.

Application Name: moneyGuru
Version: 2.8.1

Traceback (most recent call last):
  File "/Users/nelson/projects/moneyguru/qt/controller/main_window.py", line 623, in importDocument
    self.model.parse_file_for_import(docpath)
  File "/Users/nelson/projects/moneyguru/core/gui/main_window.py", line 470, in parse_file_for_import
    loader.parse(filename)
  File "/Users/nelson/projects/moneyguru/core/loader/base.py", line 222, in parse
    self._parse(infile)
  File "/Users/nelson/projects/moneyguru/core/loader/native.py", line 25, in _parse
    root = ET.parse(infile).getroot()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/xml/etree/ElementTree.py", line 1187, in parse
    tree.parse(source, parser)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/xml/etree/ElementTree.py", line 598, in parse
    self._root = parser._parse_whole(source)
LookupError: unknown encoding: USASCII

@hsoft hsoft added bug thinking labels Mar 5, 2015

@brownnrl

This comment has been minimized.

Copy link
Contributor

brownnrl commented Mar 6, 2015

While only providing QFX and CSV now (instead of QIF, QFX, OFX formats), the credit card company fixed and improved the CSV format significantly (all the same data that used to be in their QIF format), so I've gone over to using that format. It's nice that the import scripts still worked as it's performed after the loader phase. Since the immediate need is satisfied with the CSV format, I'm going to work on the fixes to the import PR instead. But I will debug that sample, and post a PR with the fix (if I can figure the issue out) and an anonymous version of the offending file.

@hsoft

This comment has been minimized.

Copy link
Owner

hsoft commented Mar 6, 2015

I don't think I've ever seen a QFX file, but I don't think moneyGuru supports it (if it's too far from a QIF, it certainly doesn't). Is it a XML file? It looks like it as moneyGuru seems to think it's a native moneyGuru file (which is XML).

@brownnrl

This comment has been minimized.

Copy link
Contributor

brownnrl commented Mar 6, 2015

It's an XML file. If I change the encoding attribute to "us" vs "USASCII" then the stack trace goes away but reads it as a CSV file. I'll see if I can review, sanitize, and post. I wouldn't have created the issue if I thought that it wasn't supported, but I assumed that it was as it's part of the narative on the moneyGuru site:

"Get it in there. moneyGuru can import QIF, OFX, QFX and CSV files and can export to QIF and CSV."

@hsoft

This comment has been minimized.

Copy link
Owner

hsoft commented Mar 6, 2015

Yeah, I don't know about that. It's been a while since I coded those routines. Back in the day, QFX files I had access to were pretty much the same as OFX (which is SGML).

... Oh, I just realize I've written "if it's too far from a QIF" earlier. It should have been "from an OFX". This is me commenting when it's too late. Anyway, if you can manage to anonymize your file and post it, it would be great.

If you want to fix it yourself, look in the OFX loader.

@brownnrl

This comment has been minimized.

Copy link
Contributor

brownnrl commented Mar 6, 2015

Yeah, it is basically just an OFX file. I experimented a bit, and saw where the loader was raising a file format exception. Instead of serializing the header in the list format (taken from here):

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

the QFX file provided by my credit card company includes the header as a processing instruction.

<?OFX
OFXHEADER="200" VERSION="200" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"
?>

Changing the header to the first key value format and changing the encoding name allowed the file content to be read. I'm going to table this until I fix that PR (working on it currently), but the approach would be to read the processing instruction in the OFX loader for the case of a QFX file.

@hsoft hsoft removed the thinking label Jul 2, 2015

@hsoft

This comment has been minimized.

Copy link
Owner

hsoft commented Jan 3, 2019

I'll just "blind fix" this on the basis of what you tried, @brownnrl, and adjust the OFX parser to accept this header and read the rest of the file as a normal OFX file.

@hsoft hsoft closed this in 7c88846 Jan 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment