spreadsheet-expr

0.0.2 • Public • Published

Spread Sheet-Expr

Parses a spreadsheet­like CSV file and evaluates each cell by

  1. Each cell is an expression in postfix notation (see Wikipedia).

  2. Each token in the expression will be separated by one or more spaces.

  3. One cell can refer to another cell with the {LETTER}{NUMBER} notation (e.g. “A2”, “B4”– letters refer to columns, numbers to rows).

  4. Expressions may include the basic arithmetic operators +, ­, *, /

This program should output another CSV file of the same dimensions containing the results

of evaluating each cell to its final value. If any cell is an invalid expression, then for that cell

For example, for the following CSV input:

b1 b2 +,2 b2 3 * ­,3 ,+

a1 ,5 , ,7 2 /

c2 3 * ,1 2 , ,5 1 2 + 4 * + 3 ­

...output something like:

­8,­13,3,#ERR

0,#ERR,0,14

Getting Started

npm install -g spreadsheet-expr

spe {source csv file path} {output csv file path}

Prerequisities

nodejs 4.x

Build from source

npm run build

Lint source code

nm lint

Run unit test

npm run test

Generate unit test converage report

npm run coverage

Note

This is a result of a programming task, please do not use this tool in production.

The design of this tool is pretty straightforward,

  1. Data parse into a 2 dimensional array (csvData), after reading from the input file

    [ [A1],[B1],[C1], [A2],[B2],[C2] ]

  2. Process content of each cells via the rpn expression engine

  3. Save execution result to a new 2 dimensional array (resultData)

  4. Finally, un-parse resultData to a string and write it to output file.

Travis build status Code Climate Test Coverage Dependency Status devDependency Status

Readme

Keywords

none

Package Sidebar

Install

npm i spreadsheet-expr

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • emmanuelkong