0

I need help, in typescript I am trying to read a cdv file in the same folder but I have an enoent error


import csv from 'csv-parser'
import fs from 'fs'
let results = new Array();



function LoadCSV(file: fs.PathLike){
    fs.createReadStream(file)
        .pipe(csv())
        .on('data', (data) => results.push(data))
        .on('end', () => {
            console.log(results);
        });
    return results;    
    
}

console.log(LoadCSV('./data.csv'));

  • 1
    That means the file can't be found at the path you specified. What does your directory structure look like? – Alex Wayne Aug 12 '20 at 16:33
  • it's a typescript application and there is a directory called api/data/ with many ts codes and an a csv file, the code below is a part of them – karim Arezki Aug 13 '20 at 07:41

0 Answers0