Comments (10)
It's definitely out of spec for every MT940 specification file I've seen so far. But if it's out there.. let's fix it :)
Pull requests are more than welcome, assuming they don't break anything else of course :)
Simply run tox
to test everything (or wait for travis to run after creating the pull request).
from mt940.
I modified the max number of lines locally and am running it against 10 months of MT940. Looks good so far, and from what I know about the format the change should not break anything. I hope I can make a pull request later today.
from mt940.
I expect to be able to review it this weekend, thanks for all the help :)
from mt940.
Ok... didn't manage that weekend but I've been able to review it now and I've merged your changes.
Thank you so much for all the help!
from mt940.
I'm getting this bug again using version 4.12.2:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-8-457c9efd8af9> in <module>
4 pprint.pprint(data)
----> 5 p = mt940.parse(data)
6
7 for transaction in p:
c:\users\edadmin\documents\risk-edzwo\.venv\lib\site-packages\mt940\parser.py in parse(src, encoding)
64
65 transactions = mt940.models.Transactions()
---> 66 transactions.parse(data)
67
68 return transactions
c:\users\edadmin\documents\risk-edzwo\.venv\lib\site-packages\mt940\models.py in parse(self, data)
417
418 for processor in self.processors.get('post_%s' % tag.slug, []):
--> 419 result = processor(self, tag, tag_dict, result)
420
421 # Creating a new transaction for :20: and :61: tags allows the
c:\users\edadmin\documents\risk-edzwo\.venv\lib\site-packages\mt940\processors.py in transaction_details_post_processor(transactions, tag, tag_dict, result)
199 # check for e.g. 103?00...
200 if re.match(r'^\d{3}\?\d{2}', details):
--> 201 result.update(_parse_mt940_details(details))
202
203 purpose = result.get('purpose')
c:\users\edadmin\documents\risk-edzwo\.venv\lib\site-packages\mt940\processors.py in _parse_mt940_details(detail_str)
139 continue
140 tmp[segment_type] = segment if not segment_type else segment[2:]
--> 141 segment_type = detail_str[index + 1] + detail_str[index + 2]
142 segment = ''
143
IndexError: string index out of range
:86:105?00FOLGELASTSCHRIFT?109250?20EREF+31HA07BC81305866B2CA4A?2
1529648D0D2?22MREF+3034.1710.5760?23CRED+DE92XXX12312319957?24SVW
Z+3722.9795.1964 HAFEL-L?25INGPING GMBH CO. KG LEXING?26E RECHNU
NG FINANZEN MONATSP?27REIS GLAUB-ID DE34ZXX123345?644095 ID
A9044ED4-A8876-?ABC123-90D?30PBBBDEFFXXX?31DE9846948540984758434?
32HAFL-LINGPING GMBH CO. KG?34992?60ABWA+HAFEL-LINGPING GMBH CO.?6
the complete mt940 has several :61 and :86 chunks, but deleting this one allows mt940.parse to do its job. The :86 is only 6 lines long though, so I'm not sure if I'm looking at the same problem here as @sbi . Running mt940.parse against a large number of transactions has resulted in this error for several of them.
from mt940.
It looks like you have a similar but different issue. Instead of being out of spec with too many lines it's got too many characters (at least with the last line).
I'll have to investigate what's going on here though. In any case line 141 of processors.py does not look defensive enough in my opinion, assumptions that multiple parts are there can be wrong.
from mt940.
thanks for your answer! I got a couple of examples like the one above, let me know how I can provide help with this issue.
from mt940.
If you can provide some (anonymized) data files that would help a lot to keep it running in the future. But I think the snippet above should already help :)
from mt940.
I got a similar issue, but this time the line ends with a ? without segment type.
A 2 liner could make _parse_mt940_details() a little bit more defensive on that kind of problem- The downside would be to silently miss some data (probably).
Should I make pull request?
from mt940.
Pull requests are always welcome :)
from mt940.
Related Issues (20)
- AttributeError: module 'mt940' has no attribute 'parse' HOT 5
- Transaction Reference Number is not returned by the parser HOT 5
- Missing essential documentation for Transaction fields. HOT 2
- Dropping Transaction Data? HOT 1
- First intermediate_opening_balance line missing HOT 5
- AttributeError: 'NoneType' object has no attribute 'encoding' HOT 1
- How to read closing, opening and available balances HOT 3
- Minor parsing errors
- Opening Balance HOT 4
- Parsing transactions : key 64 HOT 8
- Multiple accounts in one file HOT 7
- Parser doesn't show running balance or opening/closing balance at transaction level HOT 2
- Status and Fund code , when Currency ends with a D HOT 2
- Getting only single account data instead of multiple accounts HOT 1
- Non-numeric statement number HOT 2
- Exporting to tabular format HOT 1
- cannot run for citibank? HOT 1
- Single "account_identification" field HOT 2
- Statement line is parsed incorrectly for customer/bank reference HOT 2
- MT940 Issues parsing with :61: HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mt940.