在这里我得到了帮助以获取此代码,但是现在我需要查看如何实际返回CSV。我有我的代码和运行脚本的示例输出。我真的希望我能做得到。我正在使用WP All Import在我的网站上使用csv文件,并且它会上传数据,但是csv文件中有很多我不需要的东西。我将创建一个cron作业以使其每晚运行,因此我不必手动进行。
js文件:
papa.parse(file, {
worker: true,
header: true,
transformHeader: true,
step: function(result) {
let data = result.data;
data = data.filter(d => d["Mill Description"].includes('adidas') || d["Mill Description"].includes('adidaChampions'));
},
complete: function(result, csv) {
console.log("parsing complete read: ", result, csv); // Nothing is passed to here yet.
}
});
输出:
[{
"Item Number": "B12704533",
"GTIN Number": "190311332942",
"Mill Code": "04",
"Mill Description": "adidas Golf",
"Style Number": "A262",
"Mill Style Number": "TWA262S8",
"Style Name": "AD LADS MICRO STRIPE POLO",
"Color Code": "53",
"Color Description": "ROYAL",
"Size Code": "3",
"Size Description": "S",
"Unit Weight": ".7258",
"Cost": "0",
"CC": "0",
"CD": "0",
"FO": "0",
"KC": "0",
"MA": "0",
"PH": "0",
"TD": "0",
"CN": "0",
"WA": "0",
"GD": "316",
"Total Inventory": "316"
}]
[{
"Item Number": "B12704534",
"GTIN Number": "190311332966",
"Mill Code": "04",
"Mill Description": "adidas Golf",
"Style Number": "A262",
"Mill Style Number": "TWA262S8",
"Style Name": "AD LADS MICRO STRIPE POLO",
"Color Code": "53",
"Color Description": "ROYAL",
"Size Code": "4",
"Size Description": "M",
"Unit Weight": ".7717",
"Cost": "0",
"CC": "0",
"CD": "0",
"FO": "0",
"KC": "0",
"MA": "0",
"PH": "0",
"TD": "1",
"CN": "0",
"WA": "0",
"GD": "540",
"Total Inventory": "541"
}]