Comments (1)
在测试中文乱码过程中,还发现 cvs-parse
这个库,貌似有点问题,也不可能是我用的姿势不对?
像下面这样,在 finish
事件里,获取解析出来的数据,少了最后一行
const fileStream = fs.createReadStream(filePath);
const rows = [];
const parser = parse({
skip_empty_lines: true,
});
parser.on('readable', () => {
//在 finish 事件触发后,还会再触发一次readable事件,这一次,能 read 到最后一行数据
let record = null;
while(record = parser.read()){
rows.push(record);
}
});
parser.on('error', (err) => {
console.error('parser.error', err);
});
//这里应该用 end 事件
parser.on('finish', () => {
// 这里在最后一行数据之前触发,导致 rows 里,缺少了最后一行数据
console.log('finish rows: ', rows);
});
fileStream
.pipe(iconv.decodeStream('gbk'))
.pipe(parser);
给官方提了一个 issue ,看看是不是我的用法不对吧
确实是用法不对,应该用 end
事件,来最终获取结果。
from 2bugua5.
Related Issues (20)
- shell 相关
- VPN-科学上网 HOT 6
- web(前端/全链路)监控系统 HOT 3
- H5小游戏
- 开发工具
- node.js 性能相关 HOT 2
- React Native 实践 HOT 8
- TypeScript相关 HOT 3
- webview 秒开相关
- web端项目基础设施 HOT 1
- https certificate chain 等等 HOT 1
- Linux 问题集 HOT 2
- SEO优化相关
- CentOS6.5 node.js libvips sharp
- scrapy 抓取网页相关
- XSS深入理解 HOT 2
- webpack多页面打包 HOT 1
- mobile web坑全集 HOT 3
- mysql 相关 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 2bugua5.