用自定义文本替换空字符串 (PapaParse)

Replacing empty Strings with custom text (PapaParse)

PapaParse 是否可以将空字符串替换为自定义文本?我想将 JSON 导出到 CSV,但是当有一个字段中没有数据时,我想自动导出类似“MISSING DATA”的内容,而不用循环检查我的数组是否有数据

这些是我的选择:

this.csvFile = this.papa.unparse(jsonData,this.options);


  options = {
  quotes: false, //or array of booleans
  quoteChar: '""',
  delimiter: ";",
  header: false,
  skipEmptyLines: true,

}

你可以使用选项transform它应该是一个接收字段值作为参数的函数,你可以根据这个值修改它。

这是文档:https://www.papaparse.com/docs#json-to-csv

transform - A function to apply on each value. The function receives the value as its first argument and the column number or header name when enabled as its second argument. The return value of the function will replace the value it received. The transform function is applied before dynamicTyping.