博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
node.js 读取文件名_如何使用Node.js读取CSV文件
阅读量:2504 次
发布时间:2019-05-11

本文共 1180 字,大约阅读时间需要 3 分钟。

node.js 读取文件名

Many different npm modules let you read from a CSV file.

通过许多不同的npm模块,您可以读取CSV文件。

Most of them are based on , like or .

它们大多数基于 ,例如或 。

Those are great to deal with CSV in a production system.

这些非常适合在生产系统中处理CSV。

I like to keep things simple when I don’t have performance in mind. For example, for a one-time parsing of CSV that I had to do to consolidate my backend systems.

当我不考虑性能时,我喜欢保持简单。 例如,对于一次CSV解析,我不得不整合后端系统。

To do so, I used , a package that exposes the csv-parser functionality to a simple async/await interface.

为此,我使用了 ,这是一个将csv-parser功能公开给简单的async / await接口的软件包。

Install it using npm install neat-csv and require it in your app:

使用npm install neat-csv安装它,并在您的应用程序中要求它:

const neatCsv = require('neat-csv');

then load the CSV from the filesystem and invoke neatCsv passing the content of the file:

然后从文件系统加载CSV并调用neatCsv传递文件内容:

const fs = require('fs')fs.readFile('./file.csv', async (err, data) => {  if (err) {    console.error(err)    return  }  console.log(await neatCsv(data))})

Now you can start doing whatever you need to do with the data, which is formatted as a JavaScript array of objects.

现在,您可以开始处理数据,该数据被格式化为JavaScript对象数组。

翻译自:

node.js 读取文件名

转载地址:http://ptqgb.baihongyu.com/

你可能感兴趣的文章
influxdb 命令行输出时间为 yyyy-MM-dd HH:mm:ss(年月日时分秒)的方法
查看>>
已知子网掩码,确定ip地址范围
查看>>
判断时间或者数字是否连续
查看>>
docker-daemon.json各配置详解
查看>>
Docker(一)使用阿里云容器镜像服务
查看>>
Docker(三) 构建镜像
查看>>
FFmpeg 新旧版本编码 API 的区别
查看>>
RecyclerView 源码深入解析——绘制流程、缓存机制、动画等
查看>>
Android 面试题整理总结(一)Java 基础
查看>>
Android 面试题整理总结(二)Java 集合
查看>>
学习笔记_vnpy实战培训day02
查看>>
学习笔记_vnpy实战培训day03
查看>>
VNPY- VnTrader基本使用
查看>>
VNPY - CTA策略模块策略开发
查看>>
VNPY - 事件引擎
查看>>
MongoDB基本语法和操作入门
查看>>
学习笔记_vnpy实战培训day04_作业
查看>>
OCO订单(委托)
查看>>
学习笔记_vnpy实战培训day06
查看>>
回测引擎代码分析流程图
查看>>