Home > database >  csv-parser, delimiter usage
csv-parser, delimiter usage

Time:07-01

There is a csv file separated by semicolons.

The problem is solved when I replace all semicolons in the file with commas. but I want it to parse the csv file with semicolon.

const csv = require('csv-parser')
const fs = require('fs')
const results = [];

fs.createReadStream('public/event-list/event-list.csv')
  .pipe(csv({delimiter: ';'}))
  .on('data', (data) => results.push(data))
  .on('end', () => {
  
    res.render('results-page', {
      title: 'Results',
      eventsData:results
    })
  });

CodePudding user response:

Use seperator instead of delimiter

csv({separator: ';'})
  • Related