在Adam和Andre Negoi NodeJS课程之后,当我尝试使用csv解析来解析kepler_data.csv时,我遇到了这个错误。这是代码:
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();
});
});
}
我试图指示relax-quotes
,但它不起作用。我该怎么解决这个问题?
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
})