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
What is this?Papa Parse is a fast CSV (delimited text) parser for JavaScript that runs in the browser. It is RFC 4180 compliant and handles large files and malformed input gracefully.
Is it a browser-only thing, or can I use it on the server too?It is primarily an in-browser library, but it also runs in Node.js: there it can parse a Readable Stream instead of a file, and it even supports Node-style .pipe streams.
How do I add it to my project?Install the papaparse package from npm, or skip npm entirely and download papaparse.min.js straight into your project source.
Does it drag any dependencies into my bundle?None. Papa Parse has no dependencies, so it drops into any JavaScript project without pulling in anything else.
If I run it in Node.js, what works differently?Some browser-oriented options are unavailable there: LocalChunkSize, RemoteChunkSize, download, withCredentials and worker. In the Papa.NODESTREAMINPUT pipe mode, step and complete are unavailable too.
Will parsing a huge file freeze my web page?No. It can stream large files, even over HTTP, and run parsing in worker threads to keep your page reactive. You also get pause, resume and abort controls mid-parse.
What about messy CSV, like quoted fields with line breaks inside?It is RFC 4180 compliant and described as one of the only parsers that correctly handles line breaks and quotations, so malformed input does not derail it.
Can it go the other way and turn JSON into CSV?Yes. Reverse parsing is built in: give it JSON and it converts it back to CSV.
Does it auto-detect the delimiter and keep types straight?It auto-detects the delimiter and supports header rows, and it can convert numbers and booleans to their real types instead of leaving them as strings.
Creator
mholt
Size
14.5 MB
Stars
13.6K
Age
13y
Commits · 90 Days