Browse Source

adapt to new format

master
f0x 7 months ago
parent
commit
cd1a87b9f7
  1. 38
      fix.js
  2. 5
      yarn.lock

38
fix.js

@ -3,6 +3,7 @@
"use strict";
const fs = require("fs");
const os = require("os");
const chalk = require("chalk");
const path = require("path");
@ -15,11 +16,46 @@ if (process.argv[2] == null) {
let parsedPath = path.parse(absolutePath);
delete parsedPath.base;
parsedPath.name += "-fixed";
parsedPath.name += "-fixed2";
let fixedContents = contents.replace(/(^|\r\n-\r\n)ABNANL2A\r\n940\r\nABNANL2A\r\n/g, "$1");
let fixedFilename = path.format(parsedPath);
let lines = fixedContents.split(/\r?\n/);
let outputLines = [];
for (let i=0; i<lines.length; i++) {
let line = lines[i];
if (line.startsWith(":86:")) { // contents start
let desc = line;
while (!lines[i+1].startsWith(":")) {
desc += lines[i+1];
i += 1;
}
let replacements = [
"SEPA OVERBOEKING",
"SEPA PERIODIEKE OVERB.",
"IBAN: ",
"NAAM:",
"/TRTP/IBAN/",
/\/TRTP\/.+\/IBAN\//,
/\/BIC\/\w+\//,
/NAME\//,
/\/REMI\//,
/KENMERK: \w+/,
/BIC: \w+ /,
/ +(?= )/g // remove multiple spaces
]
replacements.forEach((repl) => {
desc = desc.replace(repl,' ');
})
desc = desc.replace("OMSCHRIJVING:",",");
outputLines.push(desc);
} else {
outputLines.push(line);
}
}
fixedContents = outputLines.join(os.EOL);
fs.writeFileSync(fixedFilename, fixedContents, { encoding: "utf8" })
console.log(file, "->", fixedFilename);

5
yarn.lock

@ -9,11 +9,6 @@ ansi-styles@^3.2.1:
dependencies:
color-convert "^1.9.0"
bluebird@^3.5.5:
version "3.5.5"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f"
integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==
chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"

Loading…
Cancel
Save