Node.js Read CSV File

Dec 13, 2021
npm i -S fast-csv
const csv = require('@fast-csv/parse');// with error handling and end notificationcsv.parseFile('data/data.csv')  .on('error', error => console.error(error))  .on('data', row => console.log(`ROW=${JSON.stringify(row)}`))  .on('end', rowCount => console.log(`Parsed ${rowCount} rows`));// read data with headercsv.parseFile('data/data.csv', {headers: true})  .on('data', row => {    console.log(row)  })

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.