I read a file line by line, turn each line into an array of number and push that array to a 2D array. But when I logged that 2D array, it was empty. I really don't know what's wrong here.
Here is my code:
var readline = require('readline');
var fs = require('fs');
var interface = readline.createInterface({
input: fs.createReadStream('dataset.csv')
});
var transactions = []; // declare the 2d array
interface.on('line', function (line) {
var str = line.trim().split(' ').map(Number); // turn each line to a number array
transactions.push(str); // push that number array to the 2d array
});
console.log(transactions);