swift MT940 files

Discussion in 'Perl Misc' started by Seansan, Feb 21, 2005.

  1. Seansan

    Seansan Guest

    Hi there,

    I am trying to read a bank file with a format called MT940 swift into a
    data structure. The format is as follows:

    :28C:12345/1
    :60F:C041019GBP607,20
    :61:041020C110088,00N540NONREF

    I am still learning unpack (I always used s/regex/ and then $1, $2, etc ..)
    and am wondering if someone can help me decode one of these lines e.g. the
    :60F: record. Is it even possible? The format =
    :<record>:<date,6chars><str,3><amount,0-32>

    ps. Does anyone know of a swift/mt940 module or have a script you can share?
    I searched everywhere but didnt find usefull information.

    Kind regards, Seansan
    Seansan, Feb 21, 2005
    #1
    1. Advertising

  2. Seansan

    Dave Weaver Guest

    Seansan <sheukels=cuthere=@yahooo.co.uk> wrote:
    > I am trying to read a bank file with a format called MT940 swift
    > into a data structure. The format is as follows:


    > :28C:12345/1
    > :60F:C041019GBP607,20
    > :61:041020C110088,00N540NONREF


    That isn't a format specification, it's just a sample of the data. We
    can only guess (probably incorrectly) what the format is from a sample
    data set. Especially one so brief.

    > I am still learning unpack (I always used s/regex/ and then $1, $2,
    > etc ..)

    ^
    ITYM m/regex/
    The regex approach seem best suited to this data, from what I can see
    of it.

    > and am wondering if someone can help me decode one of these lines
    > e.g. the :60F: record. Is it even possible? The format =
    > :<record>:<date,6chars><str,3><amount,0-32>


    No it isn't. Let's take another look at that line:

    > :60F:C041019GBP607,20


    What's that 'C'? Doesn't look like it's part of the date.
    And the amount after "GBP" is not in the range 0-32.
    Ignoring that:

    #!/usr/bin/perl
    use strict;
    use warnings;

    while( <DATA> ) {
    if ( /:([^:]+):C(\d{6})(...)(\d+)/ ) {
    print qq(record: "$1" date: "$2" str: "$3" amount: "$4"\n);
    }
    }

    __DATA__
    :28C:12345/1
    :60F:C041019GBP607,20
    :61:041020C110088,00N540NONREF


    this prints:
    record: "60F" date: "041019" str: "GBP" amount: "607"

    As you can see, your suggested format matches only one of those 3
    records ( and then, only if ignoring that 'C' ).

    I suggest you determine your data format first. Then it's simply a
    case of composing one or more regexs to extract the information you
    require.
    Dave Weaver, Feb 22, 2005
    #2
    1. Advertising

  3. Seansan

    JayEs Guest

    > I am trying to read a bank file with a format called MT940 swift into a
    > data structure. The format is as follows:
    >
    > :28C:12345/1
    > :60F:C041019GBP607,20
    > :61:041020C110088,00N540NONREF
    >



    OT: Swift MT940... Oh boy that brings back memories. None of it any good :)
    JayEs, Mar 1, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Niederberger

    Java class to process SWIFT files

    Simon Niederberger, Mar 1, 2004, in forum: Java
    Replies:
    0
    Views:
    390
    Simon Niederberger
    Mar 1, 2004
  2. =?Utf-8?B?SGFr?=

    Adding Swift and flash movies to .NET 2 web pages

    =?Utf-8?B?SGFr?=, Mar 1, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    344
    =?Utf-8?B?Q2hldGFuIENoYXBoZWthcg==?=
    Mar 7, 2007
  3. Sanka Piyaratna

    SWIFT interface

    Sanka Piyaratna, Jan 13, 2008, in forum: VHDL
    Replies:
    0
    Views:
    507
    Sanka Piyaratna
    Jan 13, 2008
  4. Saki
    Replies:
    2
    Views:
    2,873
    John Machin
    Mar 10, 2009
  5. _why
    Replies:
    0
    Views:
    89
Loading...

Share This Page