diff --git a/README.md b/README.md index 9e00358..eca0188 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ can be installed with the following command: npm install papaparse -If you don't want to use npm, [papaparse.min.js](https://github.com/mholt/PapaParse/blob/master/papaparse.min.js) can be downloaded to your project source. +If you don't want to use npm, [papaparse.min.js](https://unpkg.com/papaparse@latest/papaparse.min.js) can be downloaded to your project source. Homepage & Demo @@ -39,9 +39,8 @@ To learn how to use Papa Parse: - [Documentation](http://papaparse.com/docs) -The website is hosted on on [Github Pages](https://pages.github.com/). If -you want to contribute just clone the gh-branch of this repository and -open a pull request. +The website is hosted on on [Github Pages](https://pages.github.com/). It's content is also inclued on 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 diff --git a/docs/docs.html b/docs/docs.html index 1da2126..261caa2 100644 --- a/docs/docs.html +++ b/docs/docs.html @@ -99,7 +99,7 @@
-
Papa.parse(csvString[, config])
+
Papa.parse(csvString[, config])
@@ -188,7 +188,7 @@ reason: "Some reason", config: // altered config... } - to alter the flow of parsing. Actions can be "abort" to skip this and all other files in the queue, "skip" to skip just this file, or "continue" to carry on (equivalent to returning nothing). reason can be a reason for aborting. config can be a modified configuration for parsing just this file. + to alter the flow of parsing. Actions can be "abort" to skip this and all other files in the queue, "skip" to skip just this file, or "continue" to carry on (equivalent to returning nothing). reason can be a reason for aborting. config can be a modified configuration for parsing just this file.
  • The complete callback shown here is executed after all files are finished and does not receive any data. Use the complete callback in config for per-file results.
  • @@ -228,7 +228,7 @@
    -
    Papa.unparse(data[, config])
    +
    Papa.unparse(data[, config])
    @@ -243,19 +243,104 @@
  • - config is an optional object with any of these properties: -
    // defaults shown
    +								config is an optional config object
    +							
  • + +
    +
    + +
    +
    Default Unparse Config with all options
    +
    + +
    +
    
     {
    -	quotes: false,
    +	quotes: false, //or array of booleans
     	quoteChar: '"',
     	escapeChar: '"',
     	delimiter: ",",
     	header: true,
    -	newline: "\r\n"
    -}
    - Set quotes to true to always enclose each field in quotes, or an array of true/false values correlating to specific to columns to force-quote. The character used to quote can be customized using quoteChar. The character used to escape the quoteChar within a field can be customized using escapeChar. The delimiter can be any valid delimiting character. The newline character(s) may also be customized. Setting header to false will omit the header row. - - + newline: "\r\n", + skipEmptyLines: false, //or 'greedy', + columns: null //or array of strings +} +
    +
    + +
    + +
    +
    Unparse Config Options
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionExplanation
    + quotes + + If true, forces all fields to be enclosed in quotes. If an array of true/false values, specifies which fields should be force-quoted (first boolean is for the first column, second boolean for the second column, ...). +
    quoteChar + The character used to quote fields. +
    escapeChar + The character used to escape quoteChar inside field values. +
    + delimiter + + The delimiting character. It must not be found in Papa.BAD_DELIMITERS. +
    + header + + If false, will omit the header row. If data is an array of arrays this option is ignored. If data is an array of objects the keys of the first object are the header row. If data is an object with the keys fields and data the fields are the header row. +
    + newline + + The newline sequence. Must be one of "\r", "\n", or "\r\n". +
    + skipEmptyLines + + If true, lines that are completely empty (those which evaluate to an empty string) will be skipped. If set to 'greedy', lines that don't have any content (those which have only whitespace after parsing) will also be skipped. +
    + columns + + If data is an array of objects this option can be used to manually specify the keys (columns) you expect in the objects. If not set the keys of the first objects are used as column. +
    @@ -289,8 +374,8 @@ var csv = Papa.unparse([
    // Specifying fields and data explicitly
     var csv = Papa.unparse({
    -	fields: ["Column 1", "Column 2"],
    -	data: [
    +	"fields": ["Column 1", "Column 2"],
    +	"data": [
     		["foo", "bar"],
     		["abc", "def"]
     	]
    @@ -350,12 +435,14 @@ var csv = Papa.unparse({
     	complete: undefined,
     	error: undefined,
     	download: false,
    +	downloadRequestHeaders: undefined,
     	skipEmptyLines: false,
     	chunk: undefined,
     	fastMode: undefined,
     	beforeFirstChunk: undefined,
     	withCredentials: undefined,
    -	transform: undefined
    +	transform: undefined,
    +	delimitersToGuess: [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP]
     }
    @@ -375,7 +462,7 @@ var csv = Papa.unparse({ delimiter - The delimiting character. Leave blank to auto-detect from a list of most common delimiters. It can be a string or a function. If string, it must be one of length 1. If a function, it must accept the input as first parameter and it must return a string which will be used as delimiter. In both cases it cannot be found in Papa.BAD_DELIMITERS. + The delimiting character. Leave blank to auto-detect from a list of most common delimiters, or any values passed in through delimitersToGuess. It can be a string or a function. If string, it must be one of length 1. If a function, it must accept the input as first parameter and it must return a string which will be used as delimiter. In both cases it cannot be found in Papa.BAD_DELIMITERS. @@ -415,7 +502,8 @@ var csv = Papa.unparse({ transformHeader - A function to apply on each header. Requires header to be true. The function receives the header as its first argument. + A function to apply on each header. Requires header to be true. The function receives the header as its first argument.
    + Only available starting with version 5.0. @@ -431,7 +519,7 @@ var csv = Papa.unparse({ preview - If > 0, only that many rows will be parsed. + If > 0, only that many rows will be parsed. @@ -500,6 +588,19 @@ var csv = Papa.unparse({ If true, this indicates that the string you passed as the first argument to parse() is actually a URL from which to download a file and parse its contents. + + + downloadRequestHeaders + + + If defined, should be an object that describes the headers, example: + +
    +										downloadRequestHeaders: {
    +'Authorization': 'token 123345678901234567890',
    +}
    +									
    + skipEmptyLines @@ -548,6 +649,14 @@ var csv = Papa.unparse({ A function to apply on each value. The function receives the value as its first argument and the column number or header name when enabled as its second argument. The return value of the function will replace the value it received. The transform function is applied before dynamicTyping. + + + delimitersToGuess + + + An array of delimiters to guess from if the delimiter option is not set. + +
    diff --git a/docs/index.html b/docs/index.html index 5190b1d..ab427f4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -91,9 +91,6 @@ Papa.parse(bigFile, { Help - @@ -506,6 +503,7 @@ var csv = Papa.unparse(yourData);   Documentation + @@ -534,7 +532,7 @@ var csv = Papa.unparse(yourData); @@ -543,8 +541,8 @@ var csv = Papa.unparse(yourData);
    Download
    Latest (master)
    - Lil' Papa - Fat Papa + Lil' Papa + Fat Papa