CSVjsCSV 的 JavaScript 解析库
CSVjs 是一个使用纯 JavaScript 实现对 CSV 内容的编解码的库。
示例代码:
var csv = new CSV({ header: true }); csv.parse('\ "Year","Age","Marital Status","Sex","People"\n\ 1850,20,0,1,1017281\n\ 1850,20,0,2,1003841\n\ 1850,25,0,1,862547\n\ 1850,25,0,2,799482\n\ 1850,30,0,1,730638\n\ 1850,30,0,2,639636\n\ 1850,35,0,1,588487\n\ 1850,35,0,2,505012\n\ 1850,40,0,1,475911\n\ 1850,40,0,2,428185\ ');
输出结果:
{ fields: ["Year", "Age", "Marital Status", "Sex", "People"], data: [ {Year: 1850, Age: 20, Marital Status: 0, Sex: 1, People: 1017281}, {Year: 1850, Age: 20, Marital Status: 0, Sex: 2, People: 1003841}, ... ] }
评论