Skip to content
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

Lines with non-digit tags should be parsed too. #23

Closed
prometh07 opened this issue Nov 29, 2018 · 6 comments
Closed

Lines with non-digit tags should be parsed too. #23

prometh07 opened this issue Nov 29, 2018 · 6 comments

Comments

@prometh07
Copy link
Contributor

Scenario: I'm trying to parse a file with a header containing a line with a custom, non-digit tag, eg. :NS:some-description.

Available options:

  1. Ignore errors by setting Cmxl.config[:raise_line_format_errors] = false
  2. Strip headers.

None of these is helpful. However, I think there are some solutions to the problem:

  1. Change regex used to match tags in self.parse(line) inside field.rb
  2. Allow to ignore lines starting with certain tags or meeting another critiera.

I can make a PR, if you want so.

@bumi
Copy link
Contributor

bumi commented Nov 29, 2018

ahh interesting. do you have an example of such a file? I've never seen something like that so far.
What is the spec/content of those?
if they follow some standard maybe we can add proper parsing of those?

PRs are generally welcome!

@prometh07
Copy link
Contributor Author

Take a look at wolph/mt940@e4d36fe
and ftp://ftp.kamsoft.pl/pub/KS-FKW/Pomoce/MT940/PekaoBIZNES24_MC.pdf or wolph/mt940#23

Here's an example from the last link:

:20:STARTUMS
:25:1222333444
:28:1/1
:NS:22Test GmbH
23Testkonto
240,800
25010102311202
3037010000
...

@bumi
Copy link
Contributor

bumi commented Nov 29, 2018

ok, interesting... "non-swift" .

I think we should add proper support for that then.

It should be possible to simply add a new parser as described here).
And adjust the regex here to support non decimal tags.

A PR would be great! I'm happy to help if you have questions.

@prometh07
Copy link
Contributor Author

Well, so I made a tiny commit. But don't you think it would beneficial to emphasize the fact that newly defined custom field parsers are automatically added to Field.parsers hash (ie. they are used when parsing a file)? Because right now it's not entirely clear or convincing.

@bumi
Copy link
Contributor

bumi commented Jan 21, 2019

thanks, will look at it asap.
regarding your comment: you mean that should me mentioned clearly in the readme?
Just looked at the readme and you're right it is not clear that it will automatically used. -> ruby magic :)

@Uepsilon
Copy link
Contributor

fixed by merging #26, thanks @prometh07 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants