使用 NodeJS 解析 CSV 文件 [英] Parsing a CSV file using NodeJS

查看:58
本文介绍了使用 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. 转到下一行

有人可以在这里提出任何替代想法吗?

Can anyone please suggest any alternative ideas here?

推荐答案

好像需要使用基于流的库,例如 fast-csv,其中还包括验证支持.

Seems like you need to use a stream-based library such as fast-csv, which also includes validation support.

这篇关于使用 NodeJS 解析 CSV 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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