I have this error when I try to parse kepler_data.csv using csv-parse using promises following Adam and Andre Negoi NodeJS course. Here is the code:
function loadPlanetsData() {
return new Promise((resolve, reject) => {
fs.createReadStream(
path.join(__dirname, "..", "..", "data", "kepler_data.csv")
)
.pipe(
parse({
comment: "#",
columns: true,
})
)
.on("data", (data) => {
if (isHabitalePlanet(data)) {
habitablePlanets.push(data);
}
})
.on("error", (err) => {
console.log(err);
reject(err);
})
.on("end", () => {
console.log(
`${habitablePlanets.length} habitable planets found!`
);
console.log("Done reading!!");
resolve();
});
});
}
I tried to indicate relax-quotes
but it doesn't work. How can i fix this?
CodePudding user response:
parse({ comment: "#", columns: true, relax_quotes: true, escape: "\", quote: "'", delimiter: ",", ltrim: true, rtrim: true, record_delimiter: "\n", skip_empty_lines: true, relax_column_count: true, })