Papaparse - 控制台记录一行

Papaparse - console log a row

尝试 console.log() 使用 papaparse 读入一行数据,但我只是得到一个 [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));
});