Geraldziu / MT940-Converter

MIT License
0 stars 0 forks source link

MT940-Converter

A PowerShell script that converts an MT940 statement to JSON. Works with:

If you want to contact me, go to my LinkedIn and send me a message.

Example of usage

Easiest way

On Windows - Insert the _MT940Converter.psm1 file in _C:\Users\xxxx\Documents\WindowsPowerShell\Modules\MT940Converter path (the name of the folder need to be the same as the name of the file). This way you won't need to import module into powershell session

Process_Ing_MT940 -filelocation "C:\users\xxxx\Downloads\statement.sta"

More complicated way

Put the _MT940Converter.psm1 file anywhere and import this module into Powershell session

Import-Module C:\Users\xxxx\source\repos\MT940-Converter\Powershell\MT940_Converter.psm1
$savelinetovariable = Process_Ing_MT940 -filelocation "C:\users\xxxx\Downloads\statement.sta"
$savelinetovariable
Remove-Module -Name MT940_Converter

Convert the whole catalog of sta files into json files and load them into ms sql database

Put the module in the right location like in Easiest way example or import it like in More complicated way example

foreach($sta in Get-ChildItem("C:\users\xxxx\Downloads\") -Filter *.sta){
$jsonFile = "C:\users\xxxx\Downloads\statement\statement_" + $sta.Name.Substring($sta.Name.LastIndexOf("__")+2,$sta.Name.LastIndexOf(".")-$sta.Name.LastIndexOf("__")-2) + ".json"
Process_Ing_MT940 -filelocation $sta.FullName | Out-File $jsonFile
$json = Process_Ing_MT940 -filelocation $sta.FullName 
$query = "Insert into rawJson (rj_json) Values ('$json')"
#Invoke-Sqlcmd -ServerInstance '.\dev2017' -Query $query -Database 'statements'
}