在Node.js中写入CSV [英] Write to a CSV in Node.js

查看:624
本文介绍了在Node.js中写入CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难在Node.js中找到将数据写入CSV 的方法。

I am struggling to find a way to write data to a CSV in Node.js.

有几个CSV插件可用但是他们只是'写'到stdout。

There are several CSV plugins available however they only 'write' to stdout.

理想情况下我想用循环写逐行

Ideally I want to write on a row-by-row basis using a loop.

推荐答案

node-csv-parser npm install csv )具体说明它可以是与stream一起使用(参见 fromStream toStream )。因此使用stdout并不是硬编码。

The docs for node-csv-parser (npm install csv) specifically state that it can be used with streams (see fromStream, toStream). So it's not hard-coded to use stdout.

当你 npm搜索csv 时,还会出现其他几个CSV解析器 - 你可能也想看看它们。

Several other CSV parsers also come up when you npm search csv -- you might want to look at them too.

这篇关于在Node.js中写入CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆