ofxstatement
ofxstatement copied to clipboard
Commented header break OFX import process
ofxstatement comment out header in generated OFX file. That doesn't conform to OFX specification. When I try to parse the OFX file with ofxtools, I get a error because OFX file isn't conform.
Manualy uncomment header is a solution, but my purpose is to build a automatic data ingestion pipeline.
So it is possible to add a parameter in configuration to indicate to genenate a more strict OFX file, with header uncommented
@dev590t do you mean this?
<!--
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:UTF-8
CHARSET:NONE
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
-->
In general, how can I reproduce the problem myself? From what can I tell ofxtools provides ofxget utility, but it doesn't seem to work with files.
That is documentation of ofxtool about parsing OFX file: https://ofxtools.readthedocs.io/en/latest/parser.html#deviations-from-the-ofx-specification:
In [1]: from ofxtools.Parser import OFXTree
In [2]: parser = OFXTree()
In [3]: with open('2015-09_amtd.ofx', 'rb') as f: # N.B. need to open file in binary mode
...: parser.parse(f)
...:
In [4]: parser.parse('2015-09_amtd.ofx') # Can also use filename directly
If you run the code on a OFX file generated by ofxstatement, the line parser.parse('sample.ofx') of ofxtools will raise:
ofxtools.header.OFXHeaderError: OFX header is malformed:
<!--
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:UTF-8
CHARSET:NONE
COMPRESSION:NONE
OLDFILEUID:NONE
I'm trying to update a accounting tool 's importer, and switch from ofxparse to ofxtools for the parsing, because ofxparse is no longer maintained. But ofxtools expect OFX file follow strictly OFX specification, it isn't the case for OFX file generated by ofxstatement.
@kedder ,A other issue I have is when file contains special UTF-8 char, the ofx reader encounter encoding issue, uncommented the header help solve the issue.
What is purpose to have commented header?
I can try to submit a PR. Do you think the default behavior is a uncommented header, then add a parameter in configuration to allow generate commented header, that is a good solution?