JSPM

  • Created
  • Published
  • Downloads 24
  • Score
    100M100P100Q78169F
  • 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 77 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 want a new feature in this package or you would like us to change some of its functionality, raise an issue on this repo.

  • If you tried to use this library but it misbehaves, or you need advice setting it up, and its readme doesn't make sense, just document it and raise an issue on this repo.

  • If you would like to add or change some features, just fork it, hack away, and file a pull request. We'll do our best to merge it quickly. Prettier is enabled, so you don't need to worry about the code style.

⬆ back to top

Licence

MIT License (MIT)

Copyright © 2018 Codsen Ltd, Roy Revelt

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