alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

Parse csv using "csv-parser" in node js ?

Parse csv using "csv-parser" in node js ?

Could you do something like this?

 const csv = require("csv-parser");
const fs = require("fs");
const path = require("path");
const { promisify } = require("util");
const readFile = promisify(fs.readFile);

const birthdays = [];

const filePath = path.join(__dirname, "data", "groupes.csv");

readFile(filePath, "utf8").then((data) => {
  csv(data, {
    separator: ",",
  })
    .on("data", (row) => {
      birthdays.push(row);
    })
    .on("end", () => {
      console.log(birthdays);
    });
});

169 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online