【发布时间】:2020-07-25 07:34:37
【问题描述】:
我使用 d3.js 库在 Angular 中读取 CSV。这是我的阅读方式。
d3.csv('../assets/datasets/tests-per-million.csv').then((data: any) => {
this.testsData = data;
for (let i = 0; i < this.testsData.length; i++) {
this.testCountries.push(this.testsData[i].Entity.split(' ')[0]);
this.testDates.push(this.testsData[i].Date);
this.cumulativeTests.push(this.testsData[i].Cumulative);
}
});
问题在于 CSV 的最后一列在其名称中包含空格。这是 CSV 行的示例。
Entity: "Australia - units unclear"
Code: ""
Date: "Mar 22, 2020"
Cumulative total tests per million: "5632.53024026095"
我已经成功阅读了前三列,但我无法捕捉到名称中包含空格的最后一列。
【问题讨论】:
标签: javascript angular csv