New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

yi-csv

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yi-csv

读取CSV文件,并把读取结果表示成JSON对象

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

csv

读取CSV文件,并把读取结果表示成JSON对象 ##安装

    npm -g install yi-csv

##使用

引入模块

var CSV = require('yi-csv');
var csvfile = 'xxx.csv';

初始化要转换的csv文件

var readCSV = new CSV(csvfile);

或者 new CSV().init(csvfile);

调用转换函数parse,或者你可以添加相应参数,decode指定你读取的csv文件编码,默认为utf8,split指定csv文件的分隔符,默认为逗号,headers指定是否读取表头,默认不读取

//readCSV.parse({decode:'gbk',split:',',headers:true});

readCSV.parse();

转换出现错误,则触发error事件

readCSV.on('error',function(err){
    console.log(err);
});

读取完毕,触发end事件,返回数据

readCSV.on('end',function(data){
    console.log(data);
});

Keywords

csv

FAQs

Package last updated on 24 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts