【问题标题】:export array to csv Nodejs将数组导出到 csv Nodejs
【发布时间】:2015-06-03 04:23:35
【问题描述】:

我正在尝试将一组数据导出到 Nodejs 中的 CSV 文件。我正在使用 NodeCSV 模块,但每次尝试遵循示例和文档时都会出错。当我尝试使用字符串化器时,它会打印一堆代码并说字符串化器没有方法“indexOf”,当我尝试使用时它说“对象不是函数”

csv().from.array(results).to('/temp/users.csv')

如果我将 () 从 csv 中删除,它也不起作用。有谁知道如何做到这一点或可以指出一些好的文档?

【问题讨论】:

  • 试试 .to(fs.createWriteStream('/temp/users.csv'))

标签: node.js csv export-to-csv node-modules


【解决方案1】:

希望对你有更多帮助:

http.createServer(function(request, response) {
response.setHeader('Content-disposition', 'attachment; filename=testing.csv');
response.writeHead(200, {
    'Content-Type': 'text/csv'
});

csv().from(data).to(response)

}) .listen(3000);

【讨论】:

  • 我仍然在 csv() 上得到“对象不是函数”。我必须在任何地方存储从 csv() 返回的值,然后执行 res.send 或 res.sendfile 还是通过执行 .to(response) 来处理?
猜你喜欢
  • 2019-12-23
  • 2018-04-15
  • 1970-01-01
  • 2016-10-17
  • 1970-01-01
  • 1970-01-01
  • 2013-12-12
  • 2020-02-02
  • 2016-02-24
相关资源
最近更新 更多