1
我試圖跳過下面的函數的第一行或從CSV項目的標題:如何跳過CSV中第一行的項目?
importFoods() {
var csv= `foodname,category
Banana,Produce
Apple,Produce`;
var lines = csv.split("\n");
console.log('lines',lines);
for(var l in lines) {
var cols = lines[l].split(",")
console.log('cols',cols);
//0 is foodname
//1 is category
var globallistData = {
foodname: cols[0],
category: cols[1],
};
console.log(globallistData)
const globalfoods = this.db.list('/globalfoods');
globalfoods.push(globallistData);
}
}
什麼是做到這一點使用角或打字稿/ JavaScript中的最佳方式?
'lines.shift()' –