PapaParseJavaScript 的 CSV 解析庫(kù)
Papa Parse 是一個(gè)在瀏覽器上實(shí)現(xiàn)對(duì) CSV 數(shù)據(jù)的解析庫(kù),速度非???,主要特性:
- 易用
- 支持直接解析 CSV 文件,包括本地和網(wǎng)絡(luò)
- 快速模式 (真的非???/a>)
- 對(duì)超大文件進(jìn)行流處理 (甚至是 HTTP)
- 分享解析,也就是將 JSON 轉(zhuǎn)成 CSV
- 自動(dòng)檢測(cè)分隔符
- 使用工作線程確保網(wǎng)頁(yè)仍能響應(yīng)用戶的操作
- 支持表格頭
- 支持暫停、恢復(fù)和中斷
- 可轉(zhuǎn)換數(shù)字和布爾值到其他類型
- 可選的 jQuery 集成,以獲取
<input type="file">元素指定的文件 - 目前唯一支持換行和引號(hào)的解析器
Papa Parse 沒(méi)有任何依賴,甚至是 jQuery
示例代碼:
$('input[type=file]').parse({
config: {
// base config to use for each file
},
before: function(file, inputElem)
{
// executed before parsing each file begins;
// what you return here controls the flow
},
error: function(err, file, inputElem, reason)
{
// executed if an error occurs while loading the file,
// or if before callback aborted for some reason
},
complete: function()
{
// executed after all files are complete
}
});
評(píng)論
圖片
表情
