Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
node csv-parser it's not saving readed rows

I'm reading a csv files to pass it to another functions and store the records inside a database. I'm using csv-parser library, it shows on console all the lines but not stores it on an array.

const fs = require("fs");
const csv = require('csv-parser')

export const readFile = (file: string): any[] => {
  
  let lines: any[] = [];

  fs.createReadStream(`./input/${file}`)
    .pipe(csv({ separator: ';', headers: false }))
    .on('data', (data) => lines.push(Object.values(data)))
    .on('data', data => console.log(Object.values(data)))
    .on('data', data => logger.debug(`dataAccess LN 51`))
    .on('data', data => logger.debug(Object.values(data)))
    .on('end', () => {
      logger.debug(`dataAcces LN 54`);
      logger.debug([lines]);
      console.log(lines);
    });

  logger.debug(`dataAcces LN 64`);
  logger.debug([lines]);
  return [lines];

}

The lines value it's always empty array.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!