diff --git a/index.html b/index.html index 4da1e0c..6182661 100644 --- a/index.html +++ b/index.html @@ -18,267 +18,268 @@ -
-
-
-
-

Papa Parse

-

The powerful, in-browser CSV parser for big boys and girls

- - -   Download - - -   Demo - - -   Documentation - -
- -
-
// Parse CSV string
-var data = Papa.parse(csv);
-
-// Convert back to CSV
-var csv = Papa.unparse(data);
-
-// Parse local CSV file
-Papa.parse(file, {
-	complete: function(results) {
-		console.log("Finished:", results.data);
-	}
-});
-
-// Stream big file in worker thread
-Papa.parse(bigFile, {
-	worker: true,
-	step: function(results) {
-		console.log("Row:", results.data);
-	}
-});
-
-
-
-
- -
-
+
-
-
Version
4.0
-
+
+
// Parse CSV string
+	var data = Papa.parse(csv);
 
+	// Convert back to CSV
+	var csv = Papa.unparse(data);
 
-			
+ // Parse local CSV file + Papa.parse(file, { + complete: function(results) { + console.log("Finished:", results.data); + } + }); -
-
-

Features

+ // Stream big file in worker thread + Papa.parse(bigFile, { + worker: true, + step: function(results) { + console.log("Row:", results.data); + } + });
+
+ - -
-
- Now the fastest JavaScript CSV parser for the browser -
-
- The world's first multi-threaded CSV parser for the browser -
-
- Papa can handle files gigabytes in size without crashing -
-
- Use Papa when performance, privacy, and correctness matter to you -
-
- Papa alleviates privacy concerns related to uploading files -
-
- Malformed CSV is handled gracefully with a detailed error report +
+
+ +
+ +
+
Version
4.0
-
-
-
  • CSV→JSON and JSON→CSV
  • -
  • Auto-detect delimiter
  • -
  • Open local files
  • -
  • Download remote files
  • -
    -
    -
  • Stream local and remote files
  • -
  • Multi-threaded
  • -
  • Header row support
  • -
  • Type conversion
  • +
    + +
    +
    +

    Features

    +
    -
    -
  • Skip commented lines
  • -
  • Fast mode
  • -
  • Graceful error handling
  • -
  • Optional sprinkle of jQuery
  • + + +
    +
    + Now the fastest JavaScript CSV parser for the browser +
    +
    + The world's first multi-threaded CSV parser for the browser +
    +
    + Papa can handle files gigabytes in size without crashing +
    +
    + Use Papa when performance, privacy, and correctness matter to you +
    +
    + Papa alleviates privacy concerns related to uploading files +
    +
    + Malformed CSV is handled gracefully with a detailed error report +
    -
    -
    -
    +
    +
    +
  • CSV→JSON and JSON→CSV
  • +
  • Auto-detect delimiter
  • +
  • Open local files
  • +
  • Download remote files
  • +
    +
    +
  • Stream local and remote files
  • +
  • Multi-threaded
  • +
  • Header row support
  • +
  • Type conversion
  • +
    +
    +
  • Skip commented lines
  • +
  • Fast mode
  • +
  • Graceful error handling
  • +
  • Optional sprinkle of jQuery
  • +
    - -
    -
    +
    +
    +
    -
    -
    - +
    -
    -

    - SmartyStreets verifies addresses, many of which are in CSV files. Papa Parse can process huge files in the browser. "We rapidly built an awesome client-side file processor with Papa Parse." -

    -
    -
    -

    - MetaReader helps you see your data from a meta level before you start detailed analysis. "Papa Parse made it very easy to load and ready user CSV files in the browser on the client side." -

    -
    -
    -

    - EpiML is an agent-based mathematical model for the web, still in its early stages of development. "Papa makes it so easy to use CSV, which is good for scientists." -

    -
    -
    +
    +
    +
    +

    People Papa

    +
    -
    -
    - Add your link (it's free) +
    +

    + SmartyStreets verifies addresses, many of which are in CSV files. Papa Parse can process huge files in the browser. "We rapidly built an awesome client-side file processor with Papa Parse." +

    +
    +
    +

    + MetaReader helps you see your data from a meta level before you start detailed analysis. "Papa Parse made it very easy to load and ready user CSV files in the browser on the client side." +

    +
    +
    +

    + EpiML is an agent-based mathematical model for the web, still in its early stages of development. "Papa makes it so easy to use CSV, which is good for scientists." +

    +
    + +
    + +
    -
    -
    + -
    -
    -
    -

    CSV Parsing

    -
    "Isn't parsing CSV just String.split(',')?"
    - -

    Heavens, no. Papa does it right. Just pass in the CSV string with an optional configuration.

    - -
    var results = Papa.parse(csvString, config);
    -/*
    -	results = {
    -		data: [ ... ],    // parsed data
    -		errors: [ ... ],  // errors encountered
    -		meta: {	... }     // extra parse info
    -	}
    -*/
    +
    +
    +
    +

    CSV Parsing

    +
    "Isn't parsing CSV just String.split(',')?"
    + +

    Heavens, no. Papa does it right. Just pass in the CSV string with an optional configuration.

    + +
    var results = Papa.parse(csvString, config);
    +	/*
    +		results = {
    +			data: [ ... ],    // parsed data
    +			errors: [ ... ],  // errors encountered
    +			meta: {	... }     // extra parse info
    +		}
    +	*/
    +
    -
    -
    + -
    -
    -
    -

    Delimiter Detection

    -
    "But I don't know the delimiter..."
    +
    +
    +
    +

    Delimiter Detection

    +
    "But I don't know the delimiter..."
    -

    That's okay. Papa will scan the first few rows to find the right delimiter.

    +

    That's okay. Papa will scan the first few rows to find the right delimiter.

    -
    var results = Papa.parse(csvString);
    -console.log(results.meta.delimiter);
    -// "\t"
    +
    var results = Papa.parse(csvString);
    +	console.log(results.meta.delimiter);
    +	// "\t"
    +
    -
    -
    + -
    -
    -
    -

    Local Files

    -
    "Great, but I have a file to parse."
    +
    +
    +
    +

    Local Files

    +
    "Great, but I have a file to parse."
    -

    Then give Papa a File instead of a string. Since file parsing is asynchronous, don't forget a callback.

    +

    Then give Papa a File instead of a string. Since file parsing is asynchronous, don't forget a callback.

    -
    var results = Papa.parse(fileInput.files[0], {
    -	complete: function(results) {
    -		console.log(results);
    -	}
    -});
    +
    var results = Papa.parse(fileInput.files[0], {
    +		complete: function(results) {
    +			console.log(results);
    +		}
    +	});
    +
    -
    -
    + -
    -
    -
    -

    Remote Files

    -
    "No—I mean, the file isn't on my computer."
    +
    +
    +
    +

    Remote Files

    +
    "No—I mean, the file isn't on my computer."
    -

    Oh, well then just pass in the URL and—of course—a callback.

    +

    Oh, well then just pass in the URL and—of course—a callback.

    -
    Papa.parse("http://example.com/file.csv", {
    -	download: true,
    -	complete: function(results) {
    -		console.log(results);
    -	}
    -});
    +
    Papa.parse("http://example.com/file.csv", {
    +		download: true,
    +		complete: function(results) {
    +			console.log(results);
    +		}
    +	});
    +
    -
    -
    + @@ -286,259 +287,259 @@ console.log(results.meta.delimiter); -
    -
    -
    -

    Streaming

    -
    "Did I mention the file is huge?"
    - -

    That's what streaming is for. Specify a step callback to receive the results row-by-row. This way, you won't load the whole file into memory and crash the browser.

    - -
    Papa.parse("http://example.com/big.csv", {
    -	download: true,
    -	step: function(row) {
    -		console.log("Row:", row.data);
    -	},
    -	complete: function() {
    -		console.log("All done!");
    -	}
    -});
    +
    +
    +
    +

    Streaming

    +
    "Did I mention the file is huge?"
    + +

    That's what streaming is for. Specify a step callback to receive the results row-by-row. This way, you won't load the whole file into memory and crash the browser.

    + +
    Papa.parse("http://example.com/big.csv", {
    +		download: true,
    +		step: function(row) {
    +			console.log("Row:", row.data);
    +		},
    +		complete: function() {
    +			console.log("All done!");
    +		}
    +	});
    +
    -
    -
    + -
    -
    -
    -

    Multi-Threading

    -
    "Lovely. Now my web page locked up."
    - -

    That happens when a long-running script is executing in the same thread as the page. Use a Worker thread by specifying worker: true. It may take slightly longer, but your page will stay reactive.

    - -
    Papa.parse(bigFile, {
    -	worker: true,
    -	step: function(row) {
    -		console.log("Row:", row.data);
    -	},
    -	complete: function() {
    -		console.log("All done!");
    -	}
    -});
    +
    +
    +
    +

    Multi-Threading

    +
    "Lovely. Now my web page locked up."
    + +

    That happens when a long-running script is executing in the same thread as the page. Use a Worker thread by specifying worker: true. It may take slightly longer, but your page will stay reactive.

    + +
    Papa.parse(bigFile, {
    +		worker: true,
    +		step: function(row) {
    +			console.log("Row:", row.data);
    +		},
    +		complete: function() {
    +			console.log("All done!");
    +		}
    +	});
    +
    -
    -
    + - + -
    -
    -
    -

    Type Conversion

    -
    "Hey, these numbers are parsed as strings."
    +
    +
    +
    +

    Type Conversion

    +
    "Hey, these numbers are parsed as strings."
    -

    Everything is parsed as strings. If you want numbers and booleans, you can enable dynamic typing to do the conversion for you.

    +

    Everything is parsed as strings. If you want numbers and booleans, you can enable dynamic typing to do the conversion for you.

    -
    // Converts numeric/boolean data
    -var results = Papa.parse(csv, {
    -	dynamicTyping: true
    -});
    +
    // Converts numeric/boolean data
    +	var results = Papa.parse(csv, {
    +		dynamicTyping: true
    +	});
    +
    -
    -
    + -
    -
    -
    -

    Comments

    -
    "I forgot to mention: my CSV files have comments in them."
    +
    +
    +
    +

    Comments

    +
    "I forgot to mention: my CSV files have comments in them."
    -

    Okay, first off: that's really weird. But fortunately, you can skip those lines... just specify the comment string.

    +

    Okay, first off: that's really weird. But fortunately, you can skip those lines... just specify the comment string.

    -
    // Mostly found in academia, some CSV files
    -// may have commented lines in them
    -var results = Papa.parse(csv, {
    -	comments: "#"
    -});
    +
    // Mostly found in academia, some CSV files
    +	// may have commented lines in them
    +	var results = Papa.parse(csv, {
    +		comments: "#"
    +	});
    +
    -
    -
    + -
    -
    -
    -

    Error Handling

    -
    "Aw, shoot. Errors."
    - -

    Papa handles errors pretty well. The CSV standard is somewhat loose ambiguous, so Papa is designed for edge cases. For example, mismatched fields won't break parsing.

    - -
    // Example error:
    -{
    -	type: "FieldMismatch",
    -	code: "TooManyFields",
    -	message: "Expected 3 fields, but parsed 4",
    -	row: 1
    -}
    +
    +
    +
    +

    Error Handling

    +
    "Aw, shoot. Errors."
    + +

    Papa handles errors pretty well. The CSV standard is somewhat loose ambiguous, so Papa is designed for edge cases. For example, mismatched fields won't break parsing.

    + +
    // Example error:
    +	{
    +		type: "FieldMismatch",
    +		code: "TooManyFields",
    +		message: "Expected 3 fields, but parsed 4",
    +		row: 1
    +	}
    +
    -
    -
    + -
    -
    -
    -

    jQuery Plugin

    -
    "Can I use Papa with jQuery?"
    +
    +
    +
    +

    jQuery Plugin

    +
    "Can I use Papa with jQuery?"
    -

    Sure, but it's not required. You can use jQuery to select file input elements and then parse their files. Papa exposes its file parsing API as a jQuery plugin only when jQuery is defined. Papa Parse has no dependencies.

    +

    Sure, but it's not required. You can use jQuery to select file input elements and then parse their files. Papa exposes its file parsing API as a jQuery plugin only when jQuery is defined. Papa Parse has no dependencies.

    -
    $("input[type=file]").parse({
    -	config: {
    -		complete: function(results, file) {
    -			console.log("This file done:", file, results);
    +							
    $("input[type=file]").parse({
    +		config: {
    +			complete: function(results, file) {
    +				console.log("This file done:", file, results);
    +			}
    +		},
    +		complete: function() {
    +			console.log("All files done!");
     		}
    -	},
    -	complete: function() {
    -		console.log("All files done!");
    -	}
    -});
    + });
    +
    -
    -
    + -
    -
    -
    -

    JSON to CSV

    -
    "Last thing: what about converting JSON to CSV?"
    +
    +
    +
    +

    JSON to CSV

    +
    "Last thing: what about converting JSON to CSV?"
    -

    Call unparse() instead of parse(), passing in your array of arrays or array of objects. Papa will figure it out.

    +

    Call unparse() instead of parse(), passing in your array of arrays or array of objects. Papa will figure it out.

    -
    // Output is a properly-formatted CSV string.
    -// See the docs for more configurability.
    -var csv = Papa.unparse(yourData);
    +
    // Output is a properly-formatted CSV string.
    +	// See the docs for more configurability.
    +	var csv = Papa.unparse(yourData);
    +
    -
    -
    + -
    -
    -
    -

    Who's Your Papa?

    -
    +
    +
    +
    +

    Who's Your Papa?

    +
    -
    -

    - Lil' Papa - (minified) for production use -

    -
    +
    +

    + Lil' Papa + (minified) for production use +

    +
    -
    -

    - Fat Papa - (un-minified) for development -

    -
    +
    +

    + Fat Papa + (un-minified) for development +

    +
    -
    - - -
    +
    + + +
    -
    +
    - - + +