sandbox-node/fast-csv/index2.js

27 lines
516 B
JavaScript

const fs = require("fs");
const fastCsv = require("fast-csv");
const options = {
objectMode: true,
delimiter: ";",
quote: null,
headers: true,
renameHeaders: false,
};
const data = [];
const readableStream = fs.createReadStream('./210211_TicketSort_2021.csv');
fastCsv
.parseStream(readableStream, options)
.on("error", (error) => {
console.log(error);
})
.on("data", (row) => {
data.push(row);
})
.on("end", (rowCount) => {
console.log(rowCount);
console.log(data);
});