JSPM

  • Created
  • Published
  • Downloads 25
  • Score
    100M100P100Q78090F
  • License MIT

Sorts double-entry bookkeeping CSV coming from internet banking

Package Exports

  • csv-sort

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (csv-sort) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

csv-sort

Sorts double-entry bookkeeping CSV coming from internet banking

Minimum Node version required Repository is on BitBucket Coverage View dependencies as 2D chart Downloads/Month Test in browser Code style: prettier MIT License

Other siblings of this package:

Table of Contents

Install

npm i csv-sort

Here's what you'll get:

Type Key in package.json Path Size
Main export - CommonJS version, transpiled to ES5, contains require and module.exports main dist/csv-sort.cjs.js 13 KB
ES module build that Webpack/Rollup understands. Untranspiled ES6 code with import/export. module dist/csv-sort.esm.js 14 KB
UMD build for browsers, transpiled, minified, containing iife's and has all dependencies baked-in browser dist/csv-sort.umd.js 64 KB

⬆ back to top

TLDR;

csv-sort can correct the order of rows of any accounting CSV files that come in double entry bookkeeping format:

double bookkeeping example

Currently (late 2017) Lloyds Bank website exports CSV files with some rows from the same day in a wrong order. This library is my attempt to to fix such CSV's.

⬆ back to top

This library does two twings:

  • Sorts rows in correct order that follows the double-entry format.
  • Trims the empty columns and rows (so-called 2D-Trim^).

2D trim of a CSV contents

In later releases I would like to be able to recognise and fix any offset columns caused by misinterpreted commas as values.

^ 1D-Trim would be trim of a string. 3D-Trim would be some sort of spatial data trim.

⬆ back to top

Usage

const csvSort = require("csv-sort");
const input = `123456,Client #1 payment,,1000,1940
123456,Bought carpet,30,,950
123456,Bought table,10,,940
123456,Bought pens,10,,1000
123456,Bought chairs,20,,980
`;
const { res } = csvSort(input)
  .join(",")
  .join("\n");
console.log(`${`\u001b[${33}m${`res`}\u001b[${39}m`} = ${res}`);
// =>
// 123456,Client #1 payment,,1000,1940
// 123456,Bought table,10,,940
// 123456,Bought carpet,30,,950
// 123456,Bought chairs,20,,980
// 123456,Bought pens,10,,1000

⬆ back to top

API

  • Input - string
  • Output - plain object:
output object Type Description
{
res Array Array of arrays, each containing a column's value.
msgContent String This application outputs the messages here.
msgType String Can be either alert or info. That's similar to an icon on the hypothetical UI.
}

If the input is anything else than a string, it will throw. If the input is an empty string, the output object's res key will be equal to [['']].

⬆ back to top

Contributing

  • If you see an error, raise an issue.
  • If you want a new feature but can't code it up yourself, also raise an issue. Let's discuss it.
  • If you tried to use this package, but something didn't work out, also raise an issue. We'll try to help.
  • If you want to contribute some code, fork the monorepo via BitBucket, then write code, then file a pull request via BitBucket. We'll merge it in and release.

In monorepo, npm libraries are located in packages/ folder. Inside, the source code is located either in src/ folder (normal npm library) or in the root, cli.js (if it's a command line application).

The npm script "dev", the "dev": "rollup -c --dev --silent" builds the development version retaining all console.logs with row numbers. It's handy to have js-row-num-cli installed globally so you can automatically update the row numbers on all console.logs.

⬆ back to top

Licence

MIT License

Copyright (c) 2015-2019 Roy Revelt and other contributors

List of currency signs - Copyright © 2017 Ben Gourley - see its BSD-2-Clause disclaimer