sc-card-transaction-parser

This module parses the credit card logs of Standard Chartered bank and generates a JSON which can be used in whatever way you want

Usage no npm install needed!

<script type="module">
  import scCardTransactionParser from 'https://cdn.skypack.dev/sc-card-transaction-parser';
</script>

README

I wanted to analyse my credit card transactions but the transaction logs given by Standard Chartered bank is just a text file. This module returns a JSON which can be used for further analysis.

var fs = require('fs');
var sc = require('sc-card-transaction-parser');

var file = fs.readFileSync('transactions.txt');
console.log(sc.parseLog(file));

Or you can see where you are spending the most by

var fs = require('fs');
var sc = require('sc-card-transaction-parser');
var _ = require('lodash');
var file = fs.readFileSync('transactions.txt');
var transactions = sc.parseLog(file);

var expenses = function(data, type) {
  var grouped = _.groupBy(data, type);
  return _.keys(grouped).map(function(a) {
    return {
      type: a,
      amount: _.round(_.sum(grouped[a], 'amount'), 2)
    };
  });
}

console.log(_.sortBy(expenses(transactions,'desc'), function(a) {
  return a.amount;
}));

PS: I made this for my personal use and is very trivial.