I am trying to read a csv file using node js. Her is my code
fs.readFile(config.csvUploadPath, function read(err, data) {
if (err) {
throw err;
From How to read data From *.CSV file using javascript?, use the jQuery-CSV library.
Note: The library is designed to handle any CSV data that is RFC 4180 compliant, including all of the nasty edge cases that most 'simple' solutions overlook.
var fs = require('fs');
var $ = jQuery = require('jquery');
$.csv = require('jquery-csv');
var sample = './path/to/data/sample.csv';
fs.readFile(sample, 'UTF-8', function(err, csv) {
$.csv.toArrays(csv, {}, function(err, data) {
for(var i=0, len=data.length; i
code snippet from jquery-csv
's examples here.