PapaParse README

The project's README from github.com/mholt/PapaParse. As one markdown file: README.md.

Parse CSV with JavaScript

Papa Parse is the fastest in-browser CSV (or delimited text) parser for JavaScript. It is reliable and correct according to RFC 4180, and it comes with these features:

Papa Parse has no dependencies.

Install

papaparse is available on npm. It can be installed with the following command:

npm install papaparse

If you don't want to use npm, papaparse.min.js can be downloaded to your project source.

Usage

import Papa from 'papaparse';

Papa.parse(file, config);

const csv = Papa.unparse(data[, config]);

Homepage & Demo

To learn how to use Papa Parse:

The website is hosted on Github Pages. Its content is also included in the docs folder of this repository. If you want to contribute on it just clone the master of this repository and open a pull request.

Papa Parse for Node

Papa Parse can parse a Readable Stream instead of a File when used in Node.js environments (in addition to plain strings). In this mode, encoding must, if specified, be a Node-supported character encoding. The Papa.LocalChunkSize, Papa.RemoteChunkSize , download, withCredentials and worker config options are unavailable.

Papa Parse can also parse in a node streaming style which makes .pipe available. Simply pipe the Readable Stream to the stream returned from Papa.parse(Papa.NODE_STREAM_INPUT, options). The Papa.LocalChunkSize, Papa.RemoteChunkSize , download, withCredentials, worker, step, and complete config options are unavailable. To register a callback with the stream to process data, use the data event like so: stream.on('data', callback) and to signal the end of stream, use the 'end' event like so: stream.on('end', callback).

Get Started

For usage instructions, see the homepage and, for more detail, the documentation.

Tests

Papa Parse is under test. Download this repository, run npm install, then npm test to run the tests.

Contributing

To discuss a new feature open an issue. To fix a bug, submit a pull request to be credited with the contributors! Remember, a pull request, with test, is best.

If you contribute a patch, ensure the tests suite is running correctly. We run continuous integration on each pull request and will not accept a patch that breaks the tests.

PapaParse (mholt/PapaParse)

Searching Database…

13.6K ·GitHub
这是干什么的?Papa Parse 是一个快速的 JavaScript CSV(分隔符文本)解析器,可以在浏览器里运行。它符合 RFC 4180 标准,能稳定处理大文件和格式有问题的输入。
它只能在浏览器里用,还是服务器上也能用?它主要是一个浏览器端库,但也能在 Node.js 里运行:在 Node.js 中它可以解析 Readable Stream 而不是文件,甚至还支持 Node 风格的 .pipe 流。
怎么把它加到我的项目里?从 npm 安装 papaparse 包,或者完全不用 npm,直接把 papaparse.min.js 下载到你的项目源码里。
它会给我的项目带进一堆依赖吗?不会。Papa Parse 没有任何依赖,可以直接放进任何 JavaScript 项目,不需要额外安装别的东西。
如果我在 Node.js 里运行它,哪些地方不一样?一些面向浏览器的选项在那里不可用:LocalChunkSize、RemoteChunkSize、download、withCredentials 和 worker。在 Papa.NODESTREAMINPUT 管道模式下,step 和 complete 也不可用。
解析一个超大的文件会不会把我的网页卡死?不会。它可以流式处理大文件,甚至通过 HTTP 也行,还能在 worker 线程里运行解析,保持页面流畅。解析过程中你还可以随时暂停、继续和中止。
要是 CSV 很乱,比如带引号的字段里还有换行,能处理吗?可以。它符合 RFC 4180 标准,被称为少数能正确处理换行和引号的解析器之一,所以格式有问题的输入不会让它出错。
它能反过来把 JSON 转成 CSV 吗?能。反向解析是内置功能:把 JSON 给它,它就能转换回 CSV。
它能自动识别分隔符并正确处理数据类型吗?它能自动识别分隔符,支持表头行,还可以把数字和布尔值转换成真实的类型,而不是当作字符串留着。
Creator
mholt
Size
14.5 MB
Stars
13.6K
Age
13y
Commits · 90 Days