NodeJs读取csv文件 [英] NodeJs reading csv file

查看:448
本文介绍了NodeJs读取csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于nodejs,我要解析一个10000个记录的.csv文件,并对每行执行一些操作。我尝试使用 http://www.adaltas.com/projects/node-csv 。我不能让这个暂停在每一行。这只读取所有10000条记录。我需要执行以下操作:

With nodejs I want to parse a .csv file of 10000 records and do some operation on each row. I tried using http://www.adaltas.com/projects/node-csv. I couldnt get this to pause at each row. This just reads through all the 10000 records. I need to do the following

1)按行读取csv
2)对每行执行耗时操作
3)转到

1) read csv line by line 2) perform time consuming operation on each line 3) go to the next line

任何人都可以在这里提出任何建议吗?

Can anyone please suggest any alternative ideas here?

推荐答案

似乎你需要使用一些基于流的解决方案,已经存在这样的库,所以在重新发明自己之前,尝试这个库,其中还包括验证支持。 https://www.npmjs.org/package/fast-csv

Seems like you need to use some stream based solution, there existed already such libraries so before reinventing yourself, try this library, which also includes validation support. https://www.npmjs.org/package/fast-csv

这篇关于NodeJs读取csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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