gpt4 book ai didi

javascript - Papaparse - 控制台记录一行

转载 作者:行者123 更新时间:2023-12-02 14:52:54 25 4
gpt4 key购买 nike

尝试使用 papaparse 读取 console.log() 一行数据,但我只是得到一个 [object Object] 数组。如何 console.log 展开值行?

var fs = require('fs');
eval(fs.read('papaparse.min.js'));

var config = {
delimiter: "", // auto-detect
newline: "", // auto-detect
header: true,
dynamicTyping: false,
preview: 0,
encoding: "utf-8",
worker: false,
comments: false,
step: undefined,
complete: undefined,
error: undefined,
download: false,
skipEmptyLines: true,
chunk: undefined,
fastMode: undefined
};

var file = Papa.parse(fs.read('some_file.csv'), config);

for (var row in file.data) {
// this prints [object Object],[object Object], etc
console.log(file.data);

// How do I get
// value, value, value, value, etc

}

最佳答案

根据 Papa Parse 结果文档:

data is an array of rows. If header is false, rows are arrays; otherwise they are objects of data keyed by the field name.

此外,您还尝试在每次迭代中记录整个数组。数组最好不要使用for in

尝试

file.data.forEach(function(row){
console.log(JSON.stringify(row));
});

关于javascript - Papaparse - 控制台记录一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36043196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com