Crates.io | mt940 |
lib.rs | mt940 |
version | 1.0.2 |
source | src |
created_at | 2018-11-13 19:26:27.113603 |
updated_at | 2022-10-05 19:42:31.985832 |
description | A strict MT940 bank statement parser |
homepage | |
repository | https://github.com/svenstaro/mt940-rs |
max_upload_size | |
id | 96485 |
size | 470,236 |
A strict MT940 bank statement parser in Rust.
use mt940::parse_mt940;
fn main() {
let input = "\
:20:3996-11-11111111\r\n\
:25:DABADKKK/111111-11111111\r\n\
:28C:00001/001\r\n\
:60F:C090924EUR54484,04\r\n\
:61:0909250925DR583,92NMSC1110030403010139//1234\r\n\
:86:11100304030101391234\r\n\
Beneficiary name\r\n\
Something else\r\n\
:61:0910010930DR62,60NCHGcustomer id//bank id\r\n\
:86:Fees according to advice\r\n\
:62F:C090930EUR53126,94\r\n\
:64:C090930EUR53189,31\r\n\
\r\n";
let input_parsed = parse_mt940(input).unwrap();
assert_eq!(input_parsed[0].transaction_ref_no, "3996-11-11111111");
}
cargo run --bin sta2json tests/data/mt940/full/danskebank/MT940_DK_Example.sta
Documentation is here.
Time to parse the provided MT940_FI_Example.sta
:
mt940-rs (this crate) | mt940-js (NodeJS) | mt-940 (Python) | |
---|---|---|---|
Time for file | 0.054ms | 0.08ms | 1.15ms |
Performance | 600000 lines per sec | 400000 lines per sec | 28000 lines per sec |
Some banks bank use weird derivates of MT940 that do not strictly follow the specification. In that case you should try to do some pre-processing either by yourself or using one of the provided sanitizers.
Referencing proper docs is important because because banks seem to be somewhat lenient about their strictness in implementing MT940. Below I assembled a list of resources that I reference.
Amazing interactive docs.
They provide tons of good docs.