A simple CVS to Matrix parser - reads a CSV file, outputs an arrays in array (Matrix).
npm install csv-to-array-matrix
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);
}