当前位置: 软件>JavaScript软件
CSV 的 JavaScript 解析库 CSVjs
本文导语: CSVjs 是一个使用纯 JavaScript 实现对 CSV 内容的编解码的库。 示例代码: var csv = new CSV({ header: true }); csv.parse(' "Year","Age","Marital Status","Sex","People"n 1850,20,0,1,1017281n 1850,20,0,2,1003841n 1850,25,0,1,862547n 1850,25,0,2,799482n...
CSVjs 是一个使用纯 JavaScript 实现对 CSV 内容的编解码的库。
示例代码:
var csv = new CSV({ header: true }); csv.parse(' "Year","Age","Marital Status","Sex","People"n 1850,20,0,1,1017281n 1850,20,0,2,1003841n 1850,25,0,1,862547n 1850,25,0,2,799482n 1850,30,0,1,730638n 1850,30,0,2,639636n 1850,35,0,1,588487n 1850,35,0,2,505012n 1850,40,0,1,475911n 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}, ... ] }