CSV的JavaScript解析库:CSVjs

jopen 10年前

CSVjs是一个简单用于JavaScript开发中的CSV解析/编码库。

兼容浏览器,AMD和NodeJS。

示例代码:

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},      ...    ]  }

项目主页:http://www.open-open.com/lib/view/home/1401076903261