如何根据需要使用Node.js解析记录? [英] How can I parse records on demand with Node.js?

查看:102
本文介绍了如何根据需要使用Node.js解析记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可以从CSV文件解析特定数量的记录的Node模块?用例是解析大型日志文件,并根据请求将记录传送到分页客户端。

Is there a Node module that can parse a specific number of records from a CSV file? The use case is to parse a large log file and deliver records to a paging client as requested.

node-csv 无法这样做,我发现最接近的是逐行读取行,这需要重新创建CSV解析轮,并将在多行记录上中断。

node-csv can't yet do this, and the closest I've found is to read lines one by one, which requires reinventing the CSV parsing wheel, and will break on multi-line records.

但让我们降低酒吧:我如何解析单行CSV记录逐个使用Node.js?在大多数其他语言中非常小的任务。

But let's lower the bar: how can I parse single-line CSV records one by one with Node.js? Pretty trivial task in most other languages.

推荐答案

据我所知,你只想解析以逗号分隔的行值到数组?如果是,请尝试以下方法:

As far as I understand, you just want to parse the comma-separated line of values into an array? If so, try this one:

https:// npmjs .org / package / csvrow

这篇关于如何根据需要使用Node.js解析记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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