Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1007 Bytes

README.md

File metadata and controls

47 lines (30 loc) · 1007 Bytes

CSV to Matrix

Build Status

A simple CVS to Matrix parser - reads a CSV file, outputs an arrays in array (Matrix).

Installation

npm install csv-to-array-matrix

Usage

import csvToMatrix  from 'csv-to-array-matrix';

csvToMatrix('./src/data.csv', callback);

function callback(data) {
  console.log(data);
}

Transforming into a Matrix object with math.js.

import math from 'mathjs';
import csvToMatrix  from 'csv-to-array-matrix';

csvToMatrix(pathToFile, callback);

function callback(data) {
  const matrix = math.matrix(data);
}

The default delimiter is ';', but you use a different one.

import csvToMatrix  from 'csv-to-array-matrix';

csvToMatrix('./src/data.csv', callback, ',');

function callback(data) {
  console.log(data);
}