是的,我知道我应该有更好的数据,如果没有任何效果,我会修复我的数据,但我想知道是否有任何方法可以让 csv-parser 解析器解析
"United States of
America",140640,17987,2398,286,Local transmission,0
进入
{
Country: United States of America
... blah blah
... blah blah
... blah blah
... blah blah
}
fs.createReadStream("./csv/03312020.csv")
.pipe(
csv([
"Country",
"Total",
"TotalNew"
])
)
.on("data", row => {
console.log(row.Country);
let result = contains(row.Country);
if (result !== undefined) {
row.Date = today;
row.id = result + "-" + today;
if (db.dates.get(row.id) === undefined) db.dates.create(row);
}
})
.on("end", () => {
console.log("CSV file successfully processed for", today);
});
我认为 csv-parser 会看到有一个引号并将其包装为一个“列”,但显然它没有。除了重新解析我的 CSV 文件本身之外,还有更好的方法来解析这些数据吗?
慕森王
相关分类