Browse Source

Papa gets a new look

pull/180/head
Matthew Holt 10 years ago
parent
commit
d0f63a260e
  1. 2
      .gitignore
  2. 232
      demo.html
  3. 694
      docs.html
  4. 139
      faq.html
  5. BIN
      favicon.ico
  6. 595
      index.html
  7. 370
      resources/css/common.css
  8. 123
      resources/css/demo.css
  9. 272
      resources/css/home.css
  10. 93
      resources/css/tomorrow.highlight.css
  11. 12
      resources/js/common.js
  12. 1
      resources/js/highlight.min.js
  13. 54
      resources/js/home.js
  14. 52
      resources/js/lovers.js
  15. 2
      resources/js/skrollr.min.js

2
.gitignore vendored

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
.DS_Store
_gitignore/

232
demo.html

@ -5,43 +5,45 @@ @@ -5,43 +5,45 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic|Lato:300,400,700,900|Arvo">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Arvo|Source+Sans+Pro:400,400italic,700|Lato:300,400">
<link rel="stylesheet" href="/resources/css/unsemantic.css">
<link rel="stylesheet" href="/resources/css/common.css">
<link rel="stylesheet" href="/resources/css/demo.css">
<script src="/resources/js/jquery.min.js"></script>
<script src="/resources/js/papaparse.js"></script>
<script src="/resources/js/common.js"></script>
<script src="/resources/js/papaparse.js"></script>
<script src="/resources/js/demo.js"></script>
</head>
<body>
<main>
<header>
<div class="grid-container">
<div class="grid-40 mobile-grid-50">
<div class="links">
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="/demo">
<i class="fa fa-magic fa-lg"></i> Demo
</a>
<a href="/docs">
<i class="fa fa-book fa-lg"></i> Docs
</a>
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
</a>
</div>
</div>
<div class="grid-20 hide-on-mobile text-center">
<a href="/" class="text-logo">Papa Parse</a>
<a href="/" class="text-logo">Papa Parse 4</a>
</div>
<div class="grid-40 mobile-grid-50 text-right">
<div class="links">
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="https://github.com/mholt/PapaParse/issues">
<i class="fa fa-bug fa-lg"></i> Issues
<a href="http://stackoverflow.com/questions/tagged/papaparse">
<i class="fa fa-stack-overflow fa-lg"></i> Help
</a>
<a href="https://www.gratipay.com/mholt/" class="donate">
<a href="https://gratipay.com/mholt" class="donate">
<i class="fa fa-heart fa-lg"></i> Donate
</a>
</div>
@ -50,34 +52,70 @@ @@ -50,34 +52,70 @@
</header>
<h1>Choose a Demo</h1>
<main>
<div class="grid-container">
<div class="grid-100">
<h2>Try Papa Parse</h2>
<div class="tabs">
<div class="tab active" id="tab-string">String</div>
<div class="tab" id="tab-local">Local File(s)</div>
<div class="tab" id="tab-remote">Remote File</div>
<div class="tab" id="tab-unparse">JSON to CSV</div>
</div>
<div class="grid-75 push-25 grid-parent text-center">
<div class="grid-container">
<div class="grid-25">
<div class="tab active" id="tab-string">String</div>
</div>
<div class="grid-25">
<div class="tab" id="tab-local">Local file(s)</div>
</div>
<div class="grid-25">
<div class="tab" id="tab-remote">Remote file</div>
</div>
<div class="grid-25">
<div class="tab" id="tab-unparse">JSON to CSV</div>
<label>
<input type="checkbox" id="stream"> Stream
<dfn>Results are delivered row by row to a step function. Use with large inputs that would crash the browser.</dfn>
</label>
<label>
<input type="checkbox" id="worker"> Worker thread
<dfn>Uses a separate thread so the web page doesn't lock up.</dfn>
</label>
<label>
<input type="checkbox" id="header"> Header row
<dfn>Keys data by field name rather than an array.</dfn>
</label>
<label>
<input type="checkbox" id="dynamicTyping"> Dynamic typing
<dfn>Turns numeric data into numbers and true/false into booleans.</dfn>
</label>
<label>
<input type="checkbox" id="fastMode"> Fast mode
<dfn>Really fast. Only for input without quoted fields.</dfn>
</label>
</div>
<div class="clear"></div>
<div class="grid-75 grid-parent">
<div class="grid-100">
<div class="grid-33 push-66">
<label>
Delimiter:<input type="text" size="4" maxlength="1" placeholder="auto" id="delimiter"><a href="javascript:" id="insert-tab">tab</a>
<dfn>The delimiting character. Usually comma or tab. Default is comma.</dfn>
</label>
<div class="input-area" id="input-string">
<label>
Preview:<input type="number" min="0" max="1000" placeholder="0" id="preview">
<dfn>If &gt; 0, stops parsing after this many rows.</dfn>
</label>
<label>
Encoding:<input type="text" id="encoding" placeholder="default" size="7">
<dfn>Only applies when reading local files. Default is specified by the browser (usually UTF-8).</dfn>
</label>
<label>
Comment char:<input type="text" size="7" maxlength="10" placeholder="default" id="comments">
<dfn>If specified, skips lines starting with this string.</dfn>
</label>
</div>
<div class="grid-66 pull-33">
<div class="input-area" id="input-string">
<textarea id="input" placeholder="String input">Column 1,Column 2,Column 3,Column 4
1-1,1-2,1-3,1-4
2-1,2-2,2-3,2-4
@ -85,37 +123,52 @@ @@ -85,37 +123,52 @@
4,5,6,7</textarea>
</div>
<div class="input-area" id="input-local">
<p><b>Choose one or more delimited text files for Papa to parse.</b></p>
<div class="text-center">
Choose one or more delimited text files for Papa to parse.
</div>
<input type="file" id="files" multiple>
<br><br>
Or use one of these:
<br>
Sample files:
<ul>
<li>
<a href="/resources/files/normal.csv" id="local-normal-file">Normal file</a>
<br>
</li>
<li>
<a href="/resources/files/big.csv" id="local-large-file">Large file</a>
<br>
</li>
<li>
<a href="/resources/files/malformed.tsv" id="local-malformed-file">Malformed file</a>
</li>
</ul>
</div>
<div class="input-area" id="input-remote">
<p>
<b>Type the URL of the file to be downloaded and parsed.</b>
<br><small>(cross-origin requests must receive Access-Control-Allow-Origin header)</small>
</p>
<input type="text" id="url" placeholder="URL">
<br><br>
Or use one of these:
<div class="text-center">
Type the URL of the file to be downloaded and parsed.
<br>
<small>(cross-origin requests require Access-Control-Allow-Origin header)</small>
</div>
<input type="text" id="url" placeholder="URL">
Sample files:
<ul>
<li>
<a href="javascript:" id="remote-normal-file">Normal file</a>
<br>
</li>
<li>
<a href="javascript:" id="remote-large-file">Large file</a>
<br>
</li>
<li>
<a href="javascript:" id="remote-malformed-file">Malformed file</a>
</li>
</ul>
</div>
<div class="input-area" id="input-unparse">
<p><b>Paste a valid JSON string to convert to CSV.</b></p>
<textarea id="json" placeholder="JSON string">[
{
"Column 1": "1-1",
@ -143,68 +196,59 @@ @@ -143,68 +196,59 @@
}
]</textarea>
</div>
</div>
<div class="text-center">
<i class="see-results">Results will show up in the console of your browser's inspector tools.</i>
<br>
<div class="see-results">
Results will appear in the console of your browser's inspector tools
</div>
<button id="submit" class="green">Parse</button>
</div>
</div>
</div>
<div class="grid-25 pull-75 config">
<label><input type="checkbox" id="stream"> Stream</label>
<dfn>The file is loaded in chunks and results are delivered row-by-row during parsing. Saves memory and prevents crashes.</dfn>
<label><input type="checkbox" id="worker"> Worker thread</label>
<dfn>Runs the parser in a separate thread so the web page doesn't lock up.</dfn>
<label><input type="checkbox" id="header"> Header row</label>
<dfn>Keys data by field name rather than an ordered array.</dfn>
<label><input type="checkbox" id="dynamicTyping"> Dynamic typing</label>
<dfn>Turns numeric data into numbers and true/false into booleans.</dfn>
<label><input type="checkbox" id="fastMode"> Fast mode</label>
<dfn>Make sure your input doesn't have quoted fields!</dfn>
<label>Delimiter: <input type="text" size="4" maxlength="1" placeholder="auto" id="delimiter"> <a href="javascript:" id="insert-tab">use tab</a></label>
<dfn>The delimiting character. Usually comma or tab. Default is comma.</dfn>
<label>Preview: <input type="number" min="0" max="1000" placeholder="0" id="preview"></label>
<dfn>If &gt; 0, stops parsing after this many rows.</dfn>
<label>Encoding: <input type="text" id="encoding" placeholder="default" size="7"></label>
<dfn>Only applies when reading local files. Default is specified by the browser (usually UTF-8).</dfn>
<label>Comment char: <input type="text" size="7" maxlength="1" placeholder="default" id="comments"></label>
<dfn>If specified, skips lines starting with this character.</dfn>
</div>
<div class="clear"></div>
<div class="grid-100 text-center pad-50">
<hr>
<a href="https://github.com/mholt/PapaParse" class="button">
<i class="fa fa-download"></i>&nbsp; Get Papa Parse on GitHub
</a>
<a href="/docs" class="button red">
<i class="fa fa-book"></i>&nbsp; Documentation
</a>
</div>
</div>
</main>
<footer>
<!--<div class="footer-top">
<h3>Make Your Papa Proud</h3>
<h4><a href="https://github.com/mholt/PapaParse">Star</a> and <a href="https://github.com/mholt/PapaParse/blob/gh-pages/resources/js/lovers.js">shout</a> if you love #PapaParse</h4>
</div>-->
<div class="footer-main">
<div class="grid-container">
<div class="grid-100 text-center">
&copy; 2013-2014
<div class="grid-40 text-center">
<div class="logo">P</div>
<br><br>
Papa Parse by <a href="https://twitter.com/mholt6">Matt Holt</a>
<br>
Thanks to all <a href="https://github.com/mholt/jquery.parse/graphs/contributors">contributors</a>!
&copy; 2013-2015
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Learn</h5>
<a href="/demo">Demo</a>
<a href="/docs">Documentation</a>
<a href="/faq">FAQ</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Project</h5>
<a href="https://gratipay.com/mholt">Donate</a>
<a href="https://github.com/mholt/PapaParse">GitHub</a>
<a href="https://twitter.com/search?q=%23PapaParse">Share</a>
</div>
<div class="clear hide-on-desktop"></div>
<div class="grid-15 mobile-grid-50 links">
<h5>Download</h5>
<a href="https://github.com/mholt/PapaParse/archive/master.zip">Latest (master)</a>
<hr>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.min.js">Lil' Papa</a>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.js">Fat Papa</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Community</h5>
<a href="https://twitter.com/search?q=%23PapaParse">Twitter</a>
<a href="http://stackoverflow.com/questions/tagged/papaparse">Stack Overflow</a>
</div>
</div>
</div>
</footer>

694
docs.html

@ -5,41 +5,45 @@ @@ -5,41 +5,45 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic|Lato:300,400,700,900|Arvo">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Arvo|Source+Sans+Pro:400,400italic,700|Lato:300,400">
<link rel="stylesheet" href="/resources/css/unsemantic.css">
<link rel="stylesheet" href="/resources/css/tomorrow.highlight.css">
<link rel="stylesheet" href="/resources/css/common.css">
<script src="/resources/js/jquery.min.js"></script>
<script src="/resources/js/highlight.min.js"></script>
<script src="/resources/js/common.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<main>
<header>
<div class="grid-container">
<div class="grid-40 mobile-grid-50">
<div class="links">
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="/demo">
<i class="fa fa-magic fa-lg"></i> Demo
</a>
<a href="/docs">
<i class="fa fa-book fa-lg"></i> Docs
</a>
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
</a>
</div>
</div>
<div class="grid-20 hide-on-mobile text-center">
<a href="/" class="text-logo">Papa Parse</a>
<a href="/" class="text-logo">Papa Parse 4</a>
</div>
<div class="grid-40 mobile-grid-50 text-right">
<div class="links">
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="https://github.com/mholt/PapaParse/issues">
<i class="fa fa-bug fa-lg"></i> Issues
<a href="http://stackoverflow.com/questions/tagged/papaparse">
<i class="fa fa-stack-overflow fa-lg"></i> Help
</a>
<a href="https://www.gratipay.com/mholt/" class="donate">
<a href="https://gratipay.com/mholt" class="donate">
<i class="fa fa-heart fa-lg"></i> Donate
</a>
</div>
@ -47,14 +51,11 @@ @@ -47,14 +51,11 @@
</div>
</header>
<h1>Documentation</h1>
<main>
<div class="grid-container">
<h2>Documentation</h2>
<div class="prefix-33 grid-33 suffix-33">
<h4>Contents</h4>
<ol style="margin-top: 10px;">
<ol>
<li>
<a href="#csv-to-json">Convert CSV to JSON</a>
<ul>
@ -77,38 +78,29 @@ @@ -77,38 +78,29 @@
<li><a href="#extras">Extras</a></li>
</ol>
</div>
<div class="clear"></div>
</div>
<section>
<div class="grid-container">
<div class="grid-100">
<h4 id="csv-to-json">Convert CSV to JSON</h4>
<p>
Delimited data can be parsed out of strings or files. Files that are parsed can be local or remote. Local files are opened with FileReader, and remote files are downloaded with XMLHttpRequest.
</p>
</div>
<hr>
<div class="grid-100">
<h3 id="csv-to-json">Convert CSV to JSON</h3>
<p>Delimited data can be parsed out of strings or files. Files that are parsed can be local or remote. Local files are opened with FileReader, and remote files are downloaded with XMLHttpRequest.</p>
<h5 id="strings">Parse string</h5>
</div>
<div class="grid-50">
<h4 id="strings">Parse string</h4>
<code class="block">Papa.parse(csvString<i>[, <a href="#config">config</a>]</i>)</code>
<pre><code class="language-javascript">Papa.parse(csvString<i>[, <a href="#config">config</a>]</i>)</pre></code>
</div>
<div class="grid-50">
<ul>
<li><code>csvString</code> is a string of delimited text to be parsed.</li>
@ -120,11 +112,14 @@ @@ -120,11 +112,14 @@
<div class="grid-100">
<h5 id="local-files">Parse local files</h5>
</div>
<div class="grid-50">
<h4 id="local-files">Parse local file</h4>
<code class="block">Papa.parse(file, <a href="#config">config</a>)</code>
<pre><code class="language-javascript">Papa.parse(file, <a href="#config">config</a>)</code></pre>
</div>
<div class="grid-50">
<ul>
<li><code>file</code> is a <a href="https://developer.mozilla.org/en-US/docs/Web/API/File">File</a> object obtained from the DOM.</li>
@ -135,13 +130,16 @@ @@ -135,13 +130,16 @@
<div class="clear"></div>
<div class="grid-100">
<h5 id="remote-files">Parse remote file</h5>
</div>
<div class="grid-50">
<h4 id="remote-files">Parse remote file</h4>
<code class="block">Papa.parse(url, {
download: true
<span class="comment">// config ...</span>
})</code>
<pre><code class="language-javascript">Papa.parse(url, {
download: true,
// rest of config ...
})</code></pre>
</div>
<div class="grid-50">
<ul>
@ -154,10 +152,12 @@ @@ -154,10 +152,12 @@
<div class="grid-100">
<h5 id="jquery">Using jQuery to select files</h5>
</div>
<div class="grid-50">
<h4 id="jquery">Using jQuery to select files</h4>
<code class="block">$('input[type=file]').parse({
<pre><code class="language-javascript">$('input[type=file]').parse({
config: {
<span class="comment">// base <a href="#config">config</a> to use for each file</span>
},
@ -175,24 +175,26 @@ @@ -175,24 +175,26 @@
{
<span class="comment">// executed after all files are complete</span>
}
});</code>
});</code></pre>
</div>
<div class="grid-50">
<ul>
<li>Select the file input elements containing files you want to parse.</li>
<li>Select the file input elements with files you want to parse.</li>
<li>
<code>before</code> is an optional callback that lets you inspect each file before parsing begins. Return an object like:
<code class="block">{
<pre><code class="language-javascript">{
action: "abort",
reason: "Some reason",
config: <span class="comment">// altered config...</span>
}</code>
to alter the flow of parsing. Actions can be <code>"abort"</code> to skip this and all other files in the queue, <code>"skip"</code> to skip just this file, or <code>"continue"</code> to carry on (equivalent to returning nothing). <code>reason</code> can be a reason for aborting. <code>config</code> can be a modified <a href="#config">configuration</a> for parsing just this file.
}</code></pre>
to alter the flow of parsing. Actions can be <code>"abort"</code> to skip this and all other files in the queue, <code>"skip"</code> to skip just this file, or <code>"continue"</code> to carry on (equivalent to returning nothing). <code>reason</code> can be a reason for aborting. <code>config</code> can be a modified <a href="#config">configuration</a> for parsing just this file.</li>
</li>
<li>The <code>complete</code> callback shown here is executed after <i>all</i> files are finished and does not receive any data. Use the complete callback in <a href="#config">config</a> for per-file results.
<li>The <code>complete</code> callback shown here is executed after <i>all</i> files are finished and does not receive any data. Use the complete callback in <a href="#config">config</a> for per-file results.</li>
</ul>
</div>
<div class="clear"></div>
</div>
</section>
@ -208,32 +210,65 @@ @@ -208,32 +210,65 @@
<section>
<div class="grid-container">
<div class="grid-100">
<h4 id="json-to-csv">Convert JSON to CSV</h4>
<hr>
<p>
Papa's <code>unparse</code> utility writes out correct delimited text strings given an array of arrays or an array of objects.
</p>
</div>
<div class="grid-100">
<h3 id="json-to-csv">Convert JSON to CSV</h3>
<p>Papa's <code>unparse</code> utility correctly writes out delimited text strings given an array of arrays or an array of objects.</p>
<h5 id="unparse">Unparse</h5>
</div>
<div class="grid-50">
<h4 id="unparse">Unparse</h4>
<code class="block">Papa.unparse(data<i>[, config]</i>)</code>
<pre><code class="language-javascript">Papa.unparse(data<i>[, config]</i>)</code></pre>
</div>
<div class="grid-50">
<ul>
<li>Returns the resulting delimited text as a string.</li>
<li>
<code>data</code> can be one of:
<ul>
<li>An array of arrays</li>
<li>An array of objects</li>
<li>An object explicitly defining <code>fields</code> and <code>data</code></li>
</ul>
</li>
<li>
<code>config</code> is an optional object with any of these properties:
<pre><code class="language-javascript">// defaults shown
{
quotes: false,
delimiter: ",",
newline: "\r\n"
}</code></pre>
Set <code>quotes</code> to <code>true</code> to always enclose each field in quotes, or an array of true/false values correlating to specific to columns to force-quote. The <code>delimiter</code> can be any valid delimiting character. The <code>newline</code> character(s) may also be customized.
</li>
</ul>
</div>
<div class="clear"></div>
<h4 id="unparse-examples">Examples</h4>
<code class="block"><span class="comment">// Two-line, comma-delimited file</span>
<div class="grid-100">
<h5 id="unparse-examples">Examples</h5>
</div>
<div class="grid-33">
<pre><code class="language-javascript">// Two-line, comma-delimited file
var csv = Papa.unparse([
["1-1", "1-2", "1-3"],
["2-1", "2-2", "2-3"]
]);
]);</code></pre>
</div>
<span class="comment">// With header row (all objects should look alike)</span>
<div class="grid-33">
<pre><code class="language-javascript">// With implicit header row
var csv = Papa.unparse([
{
"Column 1": "foo",
@ -243,43 +278,24 @@ var csv = Papa.unparse([ @@ -243,43 +278,24 @@ var csv = Papa.unparse([
"Column 1": "abc",
"Column 2": "def"
}
]);
]);</code></pre>
</div>
<span class="comment">// Specifying fields and data manually</span>
<div class="grid-33">
<pre><code class="language-javascript">// Specifying fields and data explicitly
var csv = Papa.unparse({
fields: ["Column 1", "Column 2"],
data: [
["foo", "bar"],
["abc", "def"]
]
});
</code>
</div>
<div class="grid-50">
<ul>
<li>Returns the resulting delimited text as a string.<br><br></li>
<li>
<code>data</code> can be one of:
<ul>
<li>An array of arrays</li>
<li>An array of objects</li>
<li>An object with <code>fields</code> and <code>data</code></li>
</ul><br>
</li>
<li>
<code>config</code> is an object with any of these properties:
<code class="block"><span class="comment">// defaults shown</span>
{
quotes: false,
delimiter: ",",
newline: "\r\n"
}</code>
Set <code>quotes</code> to <code>true</code> to force enclosing each datum around quotes, or an array of true/false values correlating to specific to columns to force-quote. The <code>delimiter</code> can be any valid delimiting character. The <code>newline</code> character(s) may also be customized.
</li>
</ul>
});</code></pre>
</div>
<div class="clear"></div>
</div>
</section>
@ -295,19 +311,25 @@ var csv = Papa.unparse({ @@ -295,19 +311,25 @@ var csv = Papa.unparse({
<hr>
<section>
<div class="grid-container">
<div class="grid-100">
<h3 id="config">The Config Object</h3>
<h4 id="config">The Parse Config Object</h4>
<p>Every call to <code>parse</code> receives a configuration object. Its properties define settings, behavior, and callbacks used during parsing.</p>
<p>
The <code>parse</code> function may be passed a configuration object. It defines settings, behavior, and callbacks used during parsing. Any properties left unspecified will resort to their default values.
</p>
</div>
<div class="grid-100">
<h5 id="config-default">Default Config With All Options</h5>
</div>
<div class="grid-50">
<h4 id="config-default">Default config</h4>
<code class="block">{
<div class="prefix-25 grid-50 suffix-25">
<pre><code class="language-javascript">{
delimiter: "", // auto-detect
newline: "", // auto-detect
header: false,
@ -323,46 +345,154 @@ var csv = Papa.unparse({ @@ -323,46 +345,154 @@ var csv = Papa.unparse({
skipEmptyLines: false,
chunk: undefined,
fastMode: false
}</code>
<h4 id="config-details">Config options</h4>
<ul>
<li><code>delimiter</code> The delimiting character. Leave blank to auto-detect. If specified, it must be a string of length 1, and cannot be found in <a href="#extras">Papa.BAD_DELIMITERS</a>.</li>
<li><code>newline</code> The newline sequence. Leave blank to auto-detect. Must be one of \r, \n, or \r\n.</li>
<li><code>header</code> If true, the first row of parsed data will be interpreted as field names. Fields will be returned in the <a href="#meta">meta</a>, and each row will be an object of data keyed by field name. If false, the parser simply returns an array of arrays, including the first row.</li>
<li><code>dynamicTyping</code> If true, numeric and boolean data will be converted to their type instead of remaining strings.</li>
<li><code>preview</code> If > 0, only that many rows will be parsed.</li>
<li><code>encoding</code> The encoding to use when opening files locally.</li>
<li><code>worker</code> Whether or not to use a <a href="/faq#workers">worker thread</a>. Using a worker will keep your page reactive, but may be slightly slower.</li>
<li><code>comments</code> Specify a string that indicates a comment (like "#" or "//"). If your CSV file has commented lines, and Papa will skip them. This feature is disabled by default.</li>
</ul>
}</code></pre>
</div>
<div class="grid-50">
<ul>
<li id="step">
<code>step</code> To <a href="/faq#streaming">stream</a> the input, define a callback function to receive <a href="#results">results</a> row-by-row rather than together at the end:
<code class="block">step: function(results, handle) {
<div class="clear"></div>
<div class="grid-100">
<h5 id="config-details">Config Options</h5>
</div>
<div class="grid-100" style="overflow-x: auto;">
<table>
<tr>
<th style="width: 20%;">Option</th>
<th style="width: 80%;">Explanation</th>
</tr>
<tr>
<td>
<code>delimiter</code>
</td>
<td>
The delimiting character. Leave blank to auto-detect. If specified, it must be a string of length 1 which cannot be found in <a href="#readonly">Papa.BAD_DELIMITERS</a>.
</td>
</tr>
<tr>
<td>
<code>newline</code>
</td>
<td>
The newline sequence. Leave blank to auto-detect. Must be one of \r, \n, or \r\n.
</td>
</tr>
<tr>
<td>
<code>header</code>
</td>
<td>
If true, the first row of parsed data will be interpreted as field names. Fields will be returned in the <a href="#meta">meta</a>, and each row will be an object of data keyed by field name. If false, the parser simply returns an array of arrays, including the first row.
</td>
</tr>
<tr>
<td>
<code>dynamicTyping</code>
</td>
<td>
If true, numeric and boolean data will be converted to their type instead of remaining strings.
</td>
</tr>
<tr>
<td>
<code>preview</code>
</td>
<td>
If > 0, only that many rows will be parsed.
</td>
</tr>
<tr>
<td>
<code>encoding</code>
</td>
<td>
The encoding to use when opening local files. If specified, it must be a value supported by the FileReader API.
</td>
</tr>
<tr>
<td>
<code>worker</code>
</td>
<td>
Whether or not to use a <a href="/faq#workers">worker thread</a>. Using a worker will keep your page reactive, but may be slightly slower.
</td>
</tr>
<tr>
<td>
<code>comments</code>
</td>
<td>
A string that indicates a comment (for example, "#" or "//"). When Papa encounters a line starting with this string, it will skip the line.
</td>
</tr>
<tr>
<td>
<code>step</code>
</td>
<td>
To <a href="/faq#streaming">stream</a> the input, define a callback function:
<pre><code class="language-javascript">step: function(<a href="#results">results</a>, handle) {
console.log("Row data:", results.data);
console.log("Row errors:", results.errors);
}</code>
Except when using a worker, you can call <code>handle.abort()</code> to stop parsing, <code>handle.pause()</code> to pause it, or <code>handle.resume()</code> to resume.
</li>
<li>
<code>complete</code> A callback to execute when parsing is complete. Results are passed in, and if parsing a file, the file is, too:
<code class="block">complete: function(results, file) {
}</code></pre>
Streaming is necessary for large files which would otherwise crash the browser. Except when using a <a href="/faq#worker">Web Worker</a>, you can call <code>handle.abort()</code> to stop parsing, <code>handle.pause()</code> to pause it, or <code>handle.resume()</code> to resume.
</td>
</tr>
<tr>
<td>
<code>complete</code>
</td>
<td>
The callback to execute when parsing is complete. It receives the parse <a href="#results">results</a>. If parsing a local file, the <a href="https://developer.mozilla.org/en-US/docs/Web/API/File">File</a> is passed in, too:
<pre><code class="language-javascript">complete: function(results, file) {
console.log("Parsing complete:", results, file);
}
</code>
If streaming, results will <i>not</i> be available in this function.
</li>
<li><code>error</code> A callback to execute if FileReader encounters an error. The function should receive two arguments: the error and the File.</li>
<li><code>download</code> If true, this indicates that the string you passed in is actually a URL from which to download a file and parse it.</li>
<li><code>skipEmptyLines</code> If true, lines that are completely empty will be skipped. An empty line is defined to be one which evaluates to empty string.</li>
<li><code>chunk</code> A callback, much like step, which activates streaming and is executed after every whole chunk of the file is loaded and parsed, rather than every row. Works only with local and remote files. Do not use both chunk and step callbacks together. As arguments, it receives the results, the streamer, and if parsing a local file, the File object. You can pause, resume, and abort parsing from within this function.</li>
<li><code>fastMode</code> When enabled, fast mode executes parsing much more quickly. Only use this if you know your input won't have quoted fields.
</ul>
}</code></pre>
When streaming, parse results are <i>not</i> available in this callback.
</td>
</tr>
<tr>
<td>
<code>error</code>
</td>
<td>
A callback to execute if FileReader encounters an error. The function is passed two arguments: the error and the File.
</td>
</tr>
<tr>
<td>
<code>download</code>
</td>
<td>
If true, this indicates that the string you passed as the first argument to <code>parse()</code> is actually a URL from which to download a file and parse its contents.
</td>
</tr>
<tr>
<td>
<code>skipEmptyLines</code>
</td>
<td>
If true, lines that are completely empty will be skipped. An empty line is defined to be one which evaluates to empty string.
</td>
</tr>
<tr>
<td>
<code>chunk</code>
</td>
<td>
A callback function, identical to step, which activates streaming. However, this function is executed after every <i>chunk</i> of the file is loaded and parsed rather than every row. Works only with local and remote files. Do not use both chunk and step callbacks together. For the function signature, see the documentation for the step function.
</td>
</tr>
<tr>
<td>
<code>fastMode</code>
</td>
<td>
When enabled, fast mode executes parsing much more quickly. However, this only works for input without quoted fields. If you cannot guarantee that, do not enable fast mode.
</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
</section>
@ -385,45 +515,55 @@ var csv = Papa.unparse({ @@ -385,45 +515,55 @@ var csv = Papa.unparse({
<hr>
<section>
<div class="grid-container">
<div class="grid-100">
<h3 id="results">The Results Object</h3>
<h4 id="results">The Parse Result Object</h4>
<p>
A parse result always contains three objects: data, errors, and meta. Data and errors are arrays, and meta is an object. In the step callback, the data array will only contain one element.
</p>
</div>
<p>Parse results are always (even when streaming) provided in a roughly consistent format: an object with data, errors, and meta. When streaming, <code>results.data</code> contains only one row.</p>
<div class="grid-100">
<h5 id="results-structure">Result Structure</h5>
</div>
<div class="grid-50">
<h4 id="results-structure">Results structure</h4>
<code class="block">{
data: <span class="comment">// array of parse results</span>
errors: <span class="comment">// array of errors</span>
meta: <span class="comment">// object with extra info</span>
}</code>
<pre><code class="language-javascript">{
data: // array of parsed data
errors: // array of errors
meta: // object with extra info
}</code></pre>
</div>
<div class="grid-50">
<ul>
<li><code>data</code> is an array of rows. Rows are either arrays (if <code>header: false</code>) or objects (if <code>header: true</code>). Inside a <a href="#config">step</a> function, data will only contain one row.</li>
<li><code>errors</code> is an array of errors.</li>
<li><code>meta</code> contains extra information about the parse, such as delimiter used, number of lines, whether the process was aborted, etc.
<li><code>data</code> is an array of rows. If header is false, rows are arrays; otherwise they are objects of data keyed by the field name.</li>
<li><code>errors</code> is an array of <a href="#errors">errors</a>.</li>
<li><code>meta</code> contains extra information about the parse, such as delimiter used, the newline sequence, whether the process was aborted, etc. Properties in this object are not guaranteed to exist in all situations.</li>
</ul>
</div>
<div class="clear"></div>
<div class="grid-100">
<h5 id="data">Data</h5>
</div>
<div class="grid-50">
<h4 id="data">results.data</h4>
<code class="block"><span class="comment">// Example (without header)</span>
<pre><code class="language-javascript">// Example (header: false)
[
["Column 1", "Column 2"],
["foo", "bar"],
["abc", "def"]
]
<span class="comment">// Example (with header)</span>
// Example (header: true)
[
{
"Column 1": "foo",
@ -433,56 +573,64 @@ var csv = Papa.unparse({ @@ -433,56 +573,64 @@ var csv = Papa.unparse({
"Column 1": "abc",
"Column 2": "def"
}
]</code>
]</code></pre>
</div>
<div class="grid-50">
<ul>
<li>If header row is enabled, and more fields are found on a row of data than in the header row, an extra field will appear in the results called <code>__parsed_extra</code>. It contains an array of all data parsed from that row that was wider than the header row.</li>
<li>Using <code>dynamicTyping: true</code> will turn numeric and boolean data into number and boolean types, respectively. Otherwise, all parsed data is string.</li>
<li>If header row is enabled and more fields are found on a row of data than in the header row, an extra field will appear in that row called <code>__parsed_extra</code>. It contains an array of all data parsed from that row that extended beyond the header row.</li>
</ul>
</div>
<div class="clear"></div>
<div class="grid-100">
<h5 id="errors">Errors</h5>
</div>
<div class="grid-50">
<h4 id="errors">results.errors</h4>
<code class="block"><span class="comment">// Error structure</span>
<pre><code class="language-javascript">// Error structure
{
type: "", <span class="comment">// A generalization of the error</span>
code: "", <span class="comment">// Standardized error code</span>
message: "", <span class="comment">// Human-readable details</span>
row: 0, <span class="comment">// Row index of parsed data where error is</span>
<!--index: 0 <span class="comment">// Character index within original input</span>-->
}</code>
type: "", // A generalization of the error
code: "", // Standardized error code
message: "", // Human-readable details
row: 0, // Row index of parsed data where error is
<!--index: 0 // Character index within original input-->
}</code></pre>
</div>
<div class="grid-50">
<ul>
<li>The error <code>type</code> will be one of "Quotes", "Delimiter", or "FieldMismatch".</li>
<li>The <code>code</code> may be "MissingQuotes", "UndetectableDelimiter", "TooFewFields", or "TooManyFields" (depending on the error type).</li>
<!--<li><code>index</code> may not be available on all error messages because some errors are only generated after parsing is already complete.</li>-->
<li>Just because errors are generated does not necessarily mean that parsing failed! Papa is strong, and usually parsing only bombs hard if the input has sloppy quotes. In other words, MissingQuotes is usually a bad sign.</li>
<li>Just because errors are generated does not necessarily mean that parsing failed. The worst error you can get is probably MissingQuotes.</li>
</ul>
</div>
<div class="clear"></div>
<div class="grid-100">
<h5 id="meta">Meta</h5>
</div>
<div class="grid-50">
<h4 id="meta">results.meta</h4>
<code class="block">{
delimiter: <span class="comment">// Delimiter used</span>
linebreak: <span class="comment">// Line break sequence used</span>
aborted: <span class="comment">// Whether process was aborted</span>
fields: <span class="comment">// Array of field names</span>
truncated: <span class="comment">// Whether preview consumed all input</span>
}</code>
<pre><code class="language-javascript">{
delimiter: // Delimiter used
linebreak: // Line break sequence used
aborted: // Whether process was aborted
fields: // Array of field names
truncated: // Whether preview consumed all input
}</code></pre>
</div>
<div class="grid-50">
<ul>
<li>Not all meta properties will always be available. For instance, <code>fields</code> is only given when <code>header: true</code> is set.</li>
<li>Not all meta properties will always be available. For instance, <code>fields</code> is only given when header row is enabled.</li>
</ul>
</div>
<div class="clear"></div>
</div>
</section>
@ -495,93 +643,185 @@ var csv = Papa.unparse({ @@ -495,93 +643,185 @@ var csv = Papa.unparse({
<hr>
<section style="border-bottom: 0; padding-bottom: 0;">
<div class="grid-container">
<div class="grid-100">
<h3 id="extras">Extras</h3>
<h4 id="extras">Extras</h4>
<p>There's a few other things that Papa exposes for you that weren't explained above.</p>
<p>
There's a few other things that Papa exposes to you that weren't explained above.
</p>
</div>
<div class="grid-100">
<h5 id="readonly">Read-Only</h5>
</div>
<div class="grid-50">
<p>
These are provided as a convenience and should remain read-only, but <b>feel free to use them</b>:
</p>
<ul>
<li>
<code>Papa.BAD_DELIMITERS</code> &nbsp;
An array of characters that are not allowed as delimiters (or comment characters).
</li>
<li>
<code>Papa.RECORD_SEP</code> &nbsp;
<div class="grid-100">
<table>
<tr>
<th>Read-Only Property</th>
<th>Explanation</th>
</tr>
<tr>
<td><code>Papa.BAD_DELIMITERS</code></td>
<td>
An array of characters that are not allowed as delimiters.
</td>
</tr>
<tr>
<td><code>Papa.RECORD_SEP</code></td>
<td>
The true delimiter. Invisible. ASCII code 30. Should be doing the job we strangely rely upon commas and tabs for.
</li>
<li>
<code>Papa.UNIT_SEP</code> &nbsp;
</td>
</tr>
<tr>
<td><code>Papa.UNIT_SEP</code></td>
<td>
Also sometimes used as a delimiting character. ASCII code 31.
</li>
<li>
<code>Papa.WORKERS_SUPPORTED</code> &nbsp;
</td>
</tr>
<tr>
<td><code>Papa.WORKERS_SUPPORTED</code></td>
<td>
Whether or not the browser supports HTML5 Web Workers. If false, <code>worker: true</code> will have no effect.
</li>
</ul>
</td>
</tr>
<tr>
<td><code>Papa.SCRIPT_PATH</code></td>
<td>
The relative path to Papa Parse. This is automatically detected when Papa Parse is loaded synchronously. However, if you load Papa Parse asynchronously (e.g. with RequireJS), you need to set this variable manually in order to use Web Workers.
</td>
</tr>
</table>
</div>
<p>
Some settings you may change:
</p>
<ul>
<li>
<code>Papa.LocalChunkSize</code> &nbsp;
<div class="grid-100">
<h5 id="configurable">Configurable</h5>
</div>
<div class="grid-100">
<table>
<tr>
<th>Configurable Property</th>
<th>Explanation</th>
</tr>
<tr>
<td><code>Papa.LocalChunkSize</code></td>
<td>
The size in bytes of each file chunk. Used when streaming files obtained from the DOM that exist on the local computer. Default 10 MB.
</li>
<li>
<code>Papa.RemoteChunkSize</code> &nbsp;
</td>
</tr>
<tr>
<td><code>Papa.RemoteChunkSize</code></td>
<td>
Same as LocalChunkSize, but for downloading files from remote locations. Default 5 MB.
</li>
<li>
<code>Papa.DefaultDelimiter</code> &nbsp;
The delimiter used when one is not specified and it cannot be detected automatically. Default is comma <code>","</code>.
</li>
</td>
</tr>
<tr>
<td><code>Papa.DefaultDelimiter</code></td>
<td>
The delimiter used when one is not specified and it cannot be detected automatically. Default is comma.
</td>
</tr>
<tr>
<td><code>Papa.WORKERS_SUPPORTED</code></td>
<td>
Whether or not the browser supports HTML5 Web Workers. If false, <code>worker: true</code> will have no effect.
</td>
</tr>
</table>
</div>
<div class="grid-50">
<p>
The following items are for internal use and testing only. <b>It is not recommended that you use them unless you're familiar with the underlying code base:</b>
</p>
<ul>
<li>
<code>Papa.Parser</code> &nbsp;
The core parsing component. Careful, it's fast.
</li>
<li>
<code>Papa.ParserHandle</code> &nbsp;
<div class="grid-100">
<h5 id="internal">For Internal Use Only</h5>
</div>
<div class="grid-100">
<table>
<tr>
<th>Internal Property</th>
<th>Explanation</th>
</tr>
<tr>
<td><code>Papa.Parser</code></td>
<td>
The core parsing component. Careful, it's fast and under rigorous test.
</td>
</tr>
<tr>
<td><code>Papa.ParserHandle</code></td>
<td>
A wrapper over the Parser which provides dynamic typing and header row support.
</li>
<li>
<code>Papa.NetworkStreamer</code> &nbsp;
</td>
</tr>
<tr>
<td><code>Papa.NetworkStreamer</code></td>
<td>
Facilitates downloading and parsing files in chunks over the network with XMLHttpRequest.
</li>
<li>
<code>Papa.FileStreamer</code> &nbsp;
</td>
</tr>
<tr>
<td><code>Papa.FileStreamer</code></td>
<td>
Similar to NetworkStreamer, but for local files, and using the HTML5 FileReader.
</li>
</ul>
</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
</section>
</main>
<footer>
<!--<div class="footer-top">
<h3>Make Your Papa Proud</h3>
<h4><a href="https://github.com/mholt/PapaParse">Star</a> and <a href="https://github.com/mholt/PapaParse/blob/gh-pages/resources/js/lovers.js">shout</a> if you love #PapaParse</h4>
</div>-->
<div class="footer-main">
<div class="grid-container">
<div class="grid-100 text-center">
&copy; 2013-2014
<div class="grid-40 text-center">
<div class="logo">P</div>
<br><br>
Papa Parse by <a href="https://twitter.com/mholt6">Matt Holt</a>
<br>
Thanks to all <a href="https://github.com/mholt/jquery.parse/graphs/contributors">contributors</a>!
&copy; 2013-2015
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Learn</h5>
<a href="/demo">Demo</a>
<a href="/docs">Documentation</a>
<a href="/faq">FAQ</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Project</h5>
<a href="https://gratipay.com/mholt">Donate</a>
<a href="https://github.com/mholt/PapaParse">GitHub</a>
<a href="https://twitter.com/search?q=%23PapaParse">Share</a>
</div>
<div class="clear hide-on-desktop"></div>
<div class="grid-15 mobile-grid-50 links">
<h5>Download</h5>
<a href="https://github.com/mholt/PapaParse/archive/master.zip">Latest (master)</a>
<hr>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.min.js">Lil' Papa</a>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.js">Fat Papa</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Community</h5>
<a href="https://twitter.com/search?q=%23PapaParse">Twitter</a>
<a href="http://stackoverflow.com/questions/tagged/papaparse">Stack Overflow</a>
</div>
</div>
</div>
</footer>

139
faq.html

@ -5,41 +5,46 @@ @@ -5,41 +5,46 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic|Lato:300,400,700,900|Arvo">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Arvo|Source+Sans+Pro:400,400italic,700|Lato:300,400">
<link rel="stylesheet" href="/resources/css/unsemantic.css">
<link rel="stylesheet" href="/resources/css/tomorrow.highlight.css">
<link rel="stylesheet" href="/resources/css/common.css">
<script src="/resources/js/jquery.min.js"></script>
<script src="/resources/js/highlight.min.js"></script>
<script src="/resources/js/common.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<main>
<header>
<div class="grid-container">
<div class="grid-40 mobile-grid-50">
<div class="links">
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="/demo">
<i class="fa fa-magic fa-lg"></i> Demo
</a>
<a href="/docs">
<i class="fa fa-book fa-lg"></i> Docs
</a>
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
</a>
</div>
</div>
<div class="grid-20 hide-on-mobile text-center">
<a href="/" class="text-logo">Papa Parse</a>
<a href="/" class="text-logo">Papa Parse 4</a>
</div>
<div class="grid-40 mobile-grid-50 text-right">
<div class="links">
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="https://github.com/mholt/PapaParse/issues">
<i class="fa fa-bug fa-lg"></i> Issues
<a href="http://stackoverflow.com/questions/tagged/papaparse">
<i class="fa fa-stack-overflow fa-lg"></i> Help
</a>
<a href="https://www.gratipay.com/mholt/" class="donate">
<a href="https://gratipay.com/mholt" class="donate">
<i class="fa fa-heart fa-lg"></i> Donate
</a>
</div>
@ -47,17 +52,16 @@ @@ -47,17 +52,16 @@
</div>
</header>
<h1>FAQ</h1>
<main>
<div class="grid-container">
<h2>FAQ</h2>
<div class="prefix-20 grid-60 suffix-20">
<div class="grid-container">
<div class="prefix-15 grid-70 suffix-15">
<h3 id="general">General</h3>
<h4 id="general">General</h4>
<h4 id="why">Why use Papa Parse?</h4>
<h6 id="why">Why use Papa Parse?</h6>
<p>
There's a thousand CSV libraries for Javascript. Papa is different. It's written with correctness and performance in mind. Papa is the first (and so far only) multi-threaded CSV parser that runs on web pages. It can parse files gigabytes in size without crashing the browser. It correctly handles malformed or edge-case CSV text. It can parse files on the local file system or download them over the Internet. Papa is boss.
</p>
@ -68,38 +72,43 @@ @@ -68,38 +72,43 @@
As of version 4, Papa Parse is the <a href="http://jsperf.com/javascript-csv-parsers/4">fastest CSV parser</a> for the browser, whereas it used to be the slowest.
</p>
<h4 id="nodejs">Can I use Papa Parse server-side with Node.js?</h4>
<h6 id="nodejs">Can I use Papa Parse server-side with Node.js?</h6>
<p>
There's a fork of Papa called <a href="https://github.com/Rich-Harris/BabyParse" target="_blank">Baby Parse</a> which is <a href="https://www.npmjs.org/package/babyparse">published on npm</a>. Some features are unavailable (like worker threads and file opening/downloading), but the core parser is functional.
</p>
<h4 id="dependencies">Does Papa Parse have any dependencies?</h4>
<h6 id="dependencies">Does Papa Parse have any dependencies?</h6>
<p>
No. Papa Parse has no dependencies. If jQuery is present, however, it plugs in to make it easier to select files from the DOM.
</p>
<h4 id="browsers">Which browsers is it compatible with?</h4>
<h6 id="browsers">Which browsers is it compatible with?</h6>
<p>
All modern, competent browsers should support all of the features. However, as usual, use IE at your own risk. It looks like IE 10+ and Safari 6+ should support all the features. Firefox and Chrome should work with all features back to versions 3 and 4. Opera 11 and up should be fine. If you really need to use Papa in old IE or Opera, then keep the fancy features off and you may be in luck.
</p>
<h4 id="async">Can Papa Parse be loaded asynchronously (after the page loads)?</h4>
<h6 id="async">Can Papa Parse be loaded asynchronously (after the page loads)?</h6>
<p>
Yes. But if you want to use Web Workers, you'll need to specify the relative path to Papa Parse. To do this, set <a href="/docs#readonly">Papa.SCRIPT_PATH</a> to the relative path of the Papa Parse file. In synchronous loading, this is automatically detected.
</p>
<h6 id="combine">Can I build Papa Parse into the same file with other JS dependencies?</h6>
<p>
Not without some minor modifications. When Papa Parse loads, it has to obtain the script's relative path in order to facilitate worker threads. If you don't need this feature, Papa can be loaded asynchronously by removing or commenting a couple lines. If you do need workers, you can just hardcode the script's path. See <a href="https://github.com/mholt/PapaParse/issues/69#issuecomment-49886575">issue 69</a> and <a href="https://github.com/mholt/PapaParse/issues/87">issue 87</a> for more information.
Yes, but then don't use the Web Worker feature unless your other dependencies are battle-hardened for worker threads.
</p>
<h4 id="open-source">Is it open source? (Can I contribute something?)</h4>
<h6 id="open-source">Is it open source? (Can I contribute something?)</h6>
<p>
Yes, please! I don't want to do this all by myself. Head over to the <a href="https://github.com/mholt/PapaParse">GitHub project page</a> and hack away. If you're making a significant change, open an issue first so we can talk about it.
</p>
<h4 id="fast-mode">Why wouldn't I always enable fast mode?</h4>
<h6 id="fast-mode">Why wouldn't I always enable fast mode?</h6>
<p>
Fast mode makes <a href="http://jsperf.com/javascript-csv-parsers/3">Papa Parse screaming fast</a>, but you wouldn't want to use it if there are (or may be) quoted fields in your input. Fast mode is fast because it makes one major assumption: no quoted fields. But if you know that your input has no quotes, turn that sucker on. With fast mode on, 1 GB files can be parsed in about 20 seconds.
</p>
@ -112,28 +121,26 @@ @@ -112,28 +121,26 @@
<br><br>
<h4 id="streaming">Streaming</h4>
<hr>
<h3 id="streaming">Streaming</h3>
<h4>Can Papa load and parse huge files?</h4>
<h6>Can Papa load and parse huge files?</h6>
<p>
Yes. Parsing huge text files is facilitated by <i>streaming</i>, where the file is loaded a little bit at a time, parsed, and the results are sent to your <a href="/docs#config">step</a> callback function, row-by-row.
</p>
<h4>How do I stream my input?</h4>
<h6>How do I stream my input?</h6>
<p>
Just specify a <a href="/docs#config">step</a> callback function. Results will <i>not</i> be available after parsing is finished, however. You have to inspect the results one row at a time.
</p>
<h4>What is a stream and when should I stream files?</h4>
<h6>What is a stream and when should I stream files?</h6>
<p>
A stream is a unique data structure which, given infinite time, gives you infinite space.
So if you're short on memory (as browsers often are), use a stream.
</p>
<h4>Wait, does that mean streaming takes more time?</h4>
<h6>Wait, does that mean streaming takes more time?</h6>
<p>
Yes and no. Typically, when we gain speed, we pay with space. The opposite is true, too. Streaming uses significantly less memory with large inputs, but since the reading happens in chunks and results are processed at each row instead of at the very end, yes, it can be slower.
</p>
@ -144,26 +151,26 @@ @@ -144,26 +151,26 @@
So unless your clients have <a href="http://google.com/fiber">a fiber line</a> and you have a scalable cloud application, local parsing by streaming is nearly guaranteed to be faster.
</p>
<h4>How do I get all the results together after streaming?</h4>
<h6>How do I get all the results together after streaming?</h6>
<p>
You don't. Unless you assemble it manually. And really, don't do that... it defeats the purpose of using a stream. Just take the parts you need as they come through.
</p>
<h4>Does Papa use a true stream?</h4>
<h6>Does Papa use a true stream?</h6>
<p>
Papa uses HTML5's FileReader API which uses a stream. FileReader doesn't technically allow us to hook into the underlying stream, but it does let us load the file in pieces. But fortunately you don't have to worry about that; it's all taken care of for you. Just take the results one row at a time.
</p>
<h4>Can I stream files over a network or the Internet?</h4>
<h6>Can I stream files over a network or the Internet?</h6>
<p>
Yes, Papa Parse supports this. It will download a file in pieces using HTTP's standard Range header, then pass the parsed results to your step function just like a local file. However, these requests may not work cross-origin (different domain/hostname), depending on the server's configuration.
</p>
<p>
Streaming remote files also requires the Content-Range header in the server's response. Most production-ready servers support this header, but Python's SimpleHTTPServer does not. If you need a quick and easy server, <a href="https://github.com/rif/spark">spark</a> will do the trick. <code>./spark . -port=4100</code>
Streaming remote files also requires the Content-Range header in the server's response. Most production-ready servers support this header, but Python's SimpleHTTPServer does not. If you need a quick and easy server, <a href="https://github.com/rif/spark">spark</a> will do the trick: <code>$ ./spark</code>
</p>
<h4>Can I pause and resume parsing?</h4>
<h6>Can I pause and resume parsing?</h6>
<p>
Yes, as long as you are streaming and not using a worker. Your <a href="/docs#step">step callback</a> is passed a ParserHandle which has pause, resume, and abort functions.
</p>
@ -173,23 +180,20 @@ @@ -173,23 +180,20 @@
<br><br>
<h4 id="workers">Multi-Threading (Workers)</h4>
<hr>
<h3 id="workers">Multi-threading (Workers)</h3>
<h4>What is a web worker? Why use one?</h4>
<h6>What is a web worker? Why use one?</h6>
<p>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker">HTML5 Web Workers</a> facilitate basic multi-threading in the browser. This means that a web page can spawn a new thread in the operating system that runs Javascript code. This is highly beneficial for long-running scripts that would otherwise lock up the web page.
</p>
<h4>How do I use a worker?</h4>
<h6>How do I use a worker?</h6>
<p>
Just specify <code>worker: true</code> in your <a href="/docs#config">config</a>. You'll also need to make a <code>complete</code> callback (unless you're streaming) so that you can get the results, because using a worker makes the parse function asynchronous.
</p>
<h4>When should I use a worker?</h4>
<h6>When should I use a worker?</h6>
<p>
That's up to you. The most typical reason to use a web worker is if your web page becomes unresponsive during parsing. In other words, if it freezes and you can't click things or the scrolling becomes choppy. If that happens, some browsers (like Firefox) will warn the user that a script has become unresponsive or is taking a long time (even if it's working properly). If this happens to you or some of your users, consider using a web worker, at least for the large inputs.
</p>
@ -197,7 +201,7 @@ @@ -197,7 +201,7 @@
However, read the next answer for more info. Using workers has performance implications (both good and bad).
</p>
<h4>What are the performance implications of using a worker thread?</h4>
<h6>What are the performance implications of using a worker thread?</h6>
<p>
Using a worker will be a little slower. In Javascript, threads don't share memory. That's really annoying because sharing memory is the primary reason for multi-threading. As such, all parse results in a worker thread need to be <i>copied</i> to the main thread. And if you're parsing a string in a worker thread, that string also needs to be copied into the worker in the first place. (Files will be opened or downloaded by the worker itself, so the input doesn't need to be copied from the main thread in those cases.)
</p>
@ -209,26 +213,57 @@ @@ -209,26 +213,57 @@
</p>
<h4>Can I stream and use a worker at the same time?</h4>
<h6>Can I stream and use a worker at the same time?</h6>
<p>
Yup. If the input is too large to fit in memory (or large enough to crash the browser), streaming is <i>always</i> the answer, even in a worker thread. Workers keep the page reactive. Streaming makes it able to fit in memory. Use both if you need to.
</p>
</div>
</div>
</main>
<br><br><br>
<footer>
<!--<div class="footer-top">
<h3>Make Your Papa Proud</h3>
<h4><a href="https://github.com/mholt/PapaParse">Star</a> and <a href="https://github.com/mholt/PapaParse/blob/gh-pages/resources/js/lovers.js">shout</a> if you love #PapaParse</h4>
</div>-->
<div class="footer-main">
<div class="grid-container">
<div class="grid-100 text-center">
&copy; 2013-2014
<div class="grid-40 text-center">
<div class="logo">P</div>
<br><br>
Papa Parse by <a href="https://twitter.com/mholt6">Matt Holt</a>
<br>
Thanks to all <a href="https://github.com/mholt/jquery.parse/graphs/contributors">contributors</a>!
&copy; 2013-2015
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Learn</h5>
<a href="/demo">Demo</a>
<a href="/docs">Documentation</a>
<a href="/faq">FAQ</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Project</h5>
<a href="https://gratipay.com/mholt">Donate</a>
<a href="https://github.com/mholt/PapaParse">GitHub</a>
<a href="https://twitter.com/search?q=%23PapaParse">Share</a>
</div>
<div class="clear hide-on-desktop"></div>
<div class="grid-15 mobile-grid-50 links">
<h5>Download</h5>
<a href="https://github.com/mholt/PapaParse/archive/master.zip">Latest (master)</a>
<hr>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.min.js">Lil' Papa</a>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.js">Fat Papa</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Community</h5>
<a href="https://twitter.com/search?q=%23PapaParse">Twitter</a>
<a href="http://stackoverflow.com/questions/tagged/papaparse">Stack Overflow</a>
</div>
</div>
</div>
</footer>
</body>
</html>

BIN
favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 17 KiB

595
index.html

@ -1,24 +1,65 @@ @@ -1,24 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<title>Papa Parse - Powerful CSV parser for Javascript</title>
<title>Papa Parse - Powerful CSV Parser for JavaScript</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic|Lato:300,400,700,900|Arvo">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Arvo|Source+Sans+Pro:400,400italic,700|Lato:300,400">
<link rel="stylesheet" href="/resources/css/unsemantic.css">
<link rel="stylesheet" href="/resources/css/tomorrow.highlight.css">
<link rel="stylesheet" href="/resources/css/common.css">
<link rel="stylesheet" href="/resources/css/home.css">
<script src="/resources/js/jquery.min.js"></script>
<script src="/resources/js/skrollr.min.js"></script>
<script src="/resources/js/highlight.min.js"></script>
<script src="/resources/js/lovers.js"></script>
<script src="/resources/js/common.js"></script>
<script src="/resources/js/home.js"></script>
</head>
<body>
<div id="top-image"></div>
<div class="content">
<div id="top">
<div id="top" data-top="bottom: 0px; opacity: 1;" data-top-bottom="bottom: -350px; opacity: .3;">
<div class="grid-container">
<div class="grid-100">
<div id="title-main">
<h1>Papa Parse</h1>
<h2>A powerful, in-browser CSV parser for big boys and girls</h2>
<h2>The powerful, in-browser CSV parser for big boys and girls</h2>
<a href="https://github.com/mholt/PapaParse/archive/4.0.7.zip" class="button">
<i class="fa fa-download"></i>&nbsp; Download
</a>
<a href="/demo" class="button red">
<i class="fa fa-magic"></i>&nbsp; Demo
</a>
<a href="/docs" class="button gray">
<i class="fa fa-book"></i>&nbsp; Documentation
</a>
</div>
<div id="title-code">
<pre><code class="language-javascript">// 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);
}
});</code></pre>
</div>
</div>
</div>
</div>
<main>
@ -26,29 +67,29 @@ @@ -26,29 +67,29 @@
<div class="grid-container">
<div class="grid-40 mobile-grid-50">
<div class="links">
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="/demo">
<i class="fa fa-magic fa-lg"></i> Demo
</a>
<a href="/docs">
<i class="fa fa-book fa-lg"></i> Docs
</a>
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
</a>
</div>
</div>
<div class="grid-20 hide-on-mobile text-center">
<a href="/" class="text-logo">Papa Parse</a>
<a href="/" class="text-logo">Papa Parse 4</a>
</div>
<div class="grid-40 mobile-grid-50 text-right">
<div class="links">
<a href="/faq">
<i class="fa fa-question fa-lg"></i> FAQ
<a href="https://github.com/mholt/PapaParse">
<i class="fa fa-github fa-lg"></i> GitHub
</a>
<a href="https://github.com/mholt/PapaParse/issues">
<i class="fa fa-bug fa-lg"></i> Issues
<a href="http://stackoverflow.com/questions/tagged/papaparse">
<i class="fa fa-stack-overflow fa-lg"></i> Help
</a>
<a href="https://www.gratipay.com/mholt/" class="donate">
<a href="https://gratipay.com/mholt" class="donate">
<i class="fa fa-heart fa-lg"></i> Donate
</a>
</div>
@ -57,194 +98,203 @@ @@ -57,194 +98,203 @@
</header>
<div class="insignia">
<div class="firefox-hack">P</div>
<div class="firefox-hack"><div id="version-intro">Version</div><div id="version">4.0</div></div>
</div>
<section style="padding-top: 0;">
<div class="grid-container">
<div class="grid-100">
<div class="ticker">
<h2>
<div class="ticker-statement current">
Now the <a href="http://jsperf.com/javascript-csv-parsers/4">fastest</a> JavaScript CSV parser for the browser
<h3>Features</h3>
</div>
<div class="ticker-statement">
The world's first multi-threaded CSV parser for the browser
</div>
<div class="ticker-statement">
Use Papa when performance, privacy, and correctness matter to you
<div id="ticker">
<div class="ticker-item current">
Now the <a href="http://jsperf.com/javascript-csv-parsers/4">fastest</a> JavaScript CSV parser for the browser
</div>
<div class="ticker-statement">
Papa is easy to use:
<br>
<code>var results = Papa.parse(csv);</code>
<div class="ticker-item">
The world's first multi-threaded CSV parser for the browser
</div>
<div class="ticker-statement">
Convert JSON to CSV:
<br>
<code>var csv = Papa.unparse(json);</code>
<div class="ticker-item">
Papa can handle files gigabytes in size without crashing
</div>
<div class="ticker-statement">
Companies trust Papa to help alleviate privacy concerns related to uploading files.
<div class="ticker-item">
Use Papa when performance, privacy, and correctness matter to you
</div>
<div class="ticker-statement">
Malformed CSV is handled gracefully with a detailed error report.
<div class="ticker-item">
Papa alleviates privacy concerns related to uploading files
</div>
</h2>
<div class="ticker-item">
Malformed CSV is handled gracefully with a detailed error report
</div>
</div>
<div class="clear"></div>
<div class="grid-40">
<h3>Features</h3>
<ul>
<li>CSV &#8594; JSON and <a href="#unparse">JSON &#8594; CSV</a></li>
<div class="grid-container">
<div class="grid-33">
<li>CSV&#8594;JSON and <a href="#unparse">JSON&#8594;CSV</a></li>
<li>Auto-detect <a href="#delimiter">delimiter</a></li>
<li><a href="#local-files">Open local files</a></li>
<li><a href="#remote-files">Download remote files</a></li>
<li><a href="#stream">Stream</a> local or remote files</li>
</div>
<div class="grid-33">
<li><a href="#stream">Stream</a> local and remote files</li>
<li><a href="#worker">Multi-threaded</a></li>
<li><a href="#header">Header row</a> support</li>
<li>Number/boolean <a href="#type-conversion">type conversion</a></li>
<li>Skip <a href="#comments">commented lines</a></li>
<li>Fast mode for input without quoted fields</li>
<li><a href="#errors">Gracefully handles</a> malformed input</li>
<li>Just <a href="#jquery">a sprinkle</a> of jQuery (optional)</li>
</ul>
And Papa's <a href="http://jsperf.com/javascript-csv-parsers/4">blazing fast</a>!
<li><a href="#type-conversion">Type conversion</a></li>
</div>
<div class="grid-60">
<code class="block"><span class="comment">// Convert CSV to JSON</span>
var results = Papa.parse(csv);
<span class="comment">// Parse local CSV files</span>
$('input[type=file]').parse({
config: {
complete: function(results) {
console.log("Parse results:", results.data);
}
}
});
<span class="comment">// In a worker thread</span>
Papa.parse(fileOrString, {
worker: true,
complete: function(results) {
console.log("Parse results:", results.data);
}
});</code>
<div class="grid-33">
<li>Skip <a href="#comments">commented lines</a></li>
<li>Fast mode</li>
<li>Graceful <a href="#errors">error</a> handling</li>
<li>Optional <a href="#jquery">sprinkle</a> of jQuery</li>
</div>
<div class="clear"></div>
<br>
<br>
<div class="grid-100 text-center pad-50">
<div class="showcase">
<div class="showcase-title">
People <i class="fa fa-heart" title="Love"></i> Papa
</div>
<div class="showcase-images">
<a href="https://smartystreets.com" title="SmartyStreets" class="showcase-image smartystreets">
<img src="/resources/images/smartystreets.png" title="Fast, easy address verification">
<div class="grid-100 text-center">
<a href="https://github.com/mholt/PapaParse" class="button">
<i class="fa fa-github"></i>&nbsp; GitHub
</a>
<a href="javascript:" title="Add yours" class="showcase-image" id="showcase-add-link">
<i class="fa fa-plus fa-lg"></i>
<a href="/demo" class="button gray">
<i class="fa fa-book"></i>&nbsp; Documentation
</a>
</div>
<div class="showcase-add">
If you love your Papa, <a href="http://matt.life/contact">let me know</a> and we'll get your logo added to this page.
</div>
</section>
<section>
<div class="grid-container">
<div class="grid-100 text-center">
<h3>People <i class="fa fa-heart"></i> Papa</h3>
</div>
<a href="https://github.com/mholt/PapaParse" class="button">
<i class="fa fa-download"></i>&nbsp; Get Papa Parse on GitHub
</a>
<a href="/demo" class="button red">
<i class="fa fa-bolt"></i>&nbsp; Try the demo
</a>
<div class="grid-33">
<p class="lover">
<a href="https://smartystreets.com">SmartyStreets</a> verifies addresses, many of which are in CSV files. Papa Parse can process huge files in the browser. <i>"We rapidly built an awesome client-side file processor with Papa Parse."</i>
</p>
</div>
<div class="grid-33">
<p class="lover">
<a href="http://jannah.github.io/MetaReader/">MetaReader</a> helps you see your data from a meta level before you start detailed analysis. <i>"Papa Parse made it very easy to load and ready user CSV files in the browser on the client side."</i>
</p>
</div>
<div class="grid-33">
<p class="lover">
<a href="http://jannah.github.io/MetaReader/">EpiML</a> is an agent-based mathematical model for the web, still in its early stages of development. <i>"Papa makes it so easy to use CSV, which is good for scientists."</i>
</p>
</div>
<div class="clear"></div>
<div class="grid-100 text-center">
<br>
<b><a href="https://github.com/mholt/PapaParse/blob/gh-pages/resources/js/lovers.js" class="add-lover-link subheader"><i class="fa fa-plus-square"></i> Add your link (it's free)</a></b>
</div>
</div>
</section>
<section id="parse">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>CSV Parsing</h4>
<h5>"Isn't parsing CSV just <code>String.split(',')</code>?"</h5>
<div class="grid-40 suffix-5">
<div class="note" id="delimiter">Delimeter auto-detect</div>
<h4>"I don't know the delimiter..."</h4>
<p>
That's okay. Papa will scan the first few rows of input to find the right delimiter for you. You can also set the delimiting character manually. Either way, the delimiter used is returned with every result set.
</p>
</div>
<div class="grid-55">
<code class="block">var results = Papa.parse(csvString);
console.log(results);
<span class="comment">/*
{
data: [ ... ]
errors: [ ... ]
meta: {
delimiter: "\t",
...
}
<p>Heavens, no. Papa does it right. Just pass in the CSV string with an optional <a href="/docs#config">configuration</a>.</p>
<pre><code class="language-javascript">var results = Papa.parse(csvString, <a href="/docs#config">config</a>);
/*
results = {
data: [ ... ], // parsed data
errors: [ ... ], // errors encountered
meta: { ... } // extra parse info
}
*/</span></code>
*/</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="local-files">Parse local files</div>
<h4>"Great, but I have a <i>file</i> to parse."</h4>
<p>
Just give Papa a <a href="https://developer.mozilla.org/en-US/docs/Web/API/File">File</a> instead of a string. And a callback.
</p>
<section id="delimiter">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Delimiter Detection</h4>
<h5>"But I don't know the delimiter..."</h5>
<p>That's okay. Papa will scan the first few rows to find the right delimiter.</p>
<pre><code class="language-javascript">var results = Papa.parse(csvString);
console.log(results.meta.delimiter);
// "\t"</code></pre>
</div>
</div>
<div class="grid-55">
<code class="block">Papa.parse(file, {
</section>
<section id="local-files">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Local Files</h4>
<h5>"Great, but I have a <i>file</i> to parse."</h5>
<p>Then give Papa a <a href="https://developer.mozilla.org/en-US/docs/Web/API/File">File</a> instead of a string. Since file parsing is asynchronous, don't forget a callback.</p>
<pre><code class="language-javascript">var results = Papa.parse(fileInput.files[0], {
complete: function(results) {
console.log(results);
}
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="remote-files">Parse remote files</div>
<h4>"No, you don't understand. The file isn't local."</h4>
<p>
Well then just give Papa the URL and&mdash;of course&mdash;a callback.
</p>
</div>
<div class="grid-55">
<code class="block">Papa.parse("http://example.com/foo.csv", {
<section id="remote-files">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Remote Files</h4>
<h5>"No&mdash;I mean, the file isn't on my computer."</h5>
<p>Oh, well then just pass in the URL and&mdash;of course&mdash;a callback.</p>
<pre><code class="language-javascript">Papa.parse("http://example.com/file.csv", {
download: true,
complete: function(results) {
console.log("Remote file parsed!", results);
console.log(results);
}
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="stream">Streaming</div>
<h4>"Did I mention the file is huge?"</h4>
<p>
That's what streaming is for. Specify a <code>step</code> callback to receive the results row-by-row. This way, you won't load the whole file into memory and crash the browser.
</p>
</div>
<div class="grid-55">
<code class="block">Papa.parse("http://example.com/bigfoo.csv", {
<section id="stream">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Streaming</h4>
<h5>"Did I mention the file is huge?"</h5>
<p>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.</p>
<pre><code class="language-javascript">Papa.parse("http://example.com/big.csv", {
download: true,
step: function(row) {
console.log("Row:", row.data);
@ -252,23 +302,22 @@ console.log(results); @@ -252,23 +302,22 @@ console.log(results);
complete: function() {
console.log("All done!");
}
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<section id="worker">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Multi-Threading</h4>
<h5>"Lovely. Now my web page locked up."</h5>
<div class="grid-40 suffix-5">
<div class="note" id="worker">Multi-threading</div>
<h4>"Lovely. Now my web page locked up."</h4>
<p>
Oh. Yeah, that happens when a long-running script is executing in the same thread. Use a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker">Worker</a> thread by specifying <code>worker: true</code>. It may take slightly longer, but your page will stay reactive.
</p>
</div>
<div class="grid-55">
<code class="block">Papa.parse(bigFile, {
<p>That happens when a long-running script is executing in the same thread as the page. Use a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker">Worker</a> thread by specifying <code>worker: true</code>. It may take slightly longer, but your page will stay reactive.</p>
<pre><code class="language-javascript">Papa.parse(bigFile, {
worker: true,
step: function(row) {
console.log("Row:", row.data);
@ -276,174 +325,220 @@ console.log(results); @@ -276,174 +325,220 @@ console.log(results);
complete: function() {
console.log("All done!");
}
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="header">Header Rows</div>
<h4>"Great! Now I want data keyed by field name."</h4>
<p>
You can tell Papa that there is a header row.
</p>
</div>
<div class="grid-55">
<code class="block"><span class="comment">// Key data by field name instead of index/position</span>
<section id="header">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Header Row</h4>
<h5>"Great! Now I want data keyed by field name."</h5>
<p>If you tell Papa there is a header row, each row will be organized by field name instead of index.</p>
<pre><code class="language-javascript">// Key data by field name instead of index/position
var results = Papa.parse(csv, {
header: true
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="type-conversion">Type Conversion</div>
<h4>"Hey, these numbers are all parsed as strings."</h4>
<p>
Everything is parsed as strings. If you need the convenience, you can have numeric and boolean data automatically converted to number and boolean types.
</p>
</div>
<div class="grid-55">
<code class="block"><span class="comment">// All parsed data is normally returned as a string.
// Dynamic typing converts numbers to numbers
// and booleans to booleans.</span>
<section id="type-conversion">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Type Conversion</h4>
<h5>"Hey, these numbers are parsed as strings."</h5>
<p><i>Everything</i> is parsed as strings. If you want numbers and booleans, you can enable dynamic typing to do the conversion for you.</p>
<pre><code class="language-javascript">// Converts numeric/boolean data
var results = Papa.parse(csv, {
dynamicTyping: true
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="comments">Comments</div>
<h4>"I forgot to mention: my CSV files have comments in them."</h4>
<p>
Okay, first off: that's really weird. But you can skip those lines... just specify the comment character.
</p>
</div>
<div class="grid-55">
<code class="block"><span class="comment">// Mostly found in academia, some CSV files
// may have commented lines in them</span>
<section id="comments">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Comments</h4>
<h5>"I forgot to mention: my CSV files have comments in them."</h5>
<p>Okay, first off: that's really weird. But fortunately, you can skip those lines... just specify the comment string.</p>
<pre><code class="language-javascript">// Mostly found in academia, some CSV files
// may have commented lines in them
var results = Papa.parse(csv, {
comments: "#"
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="errors">Error handling</div>
<h4>"I'm getting tired, are we done&mdash;aw, shoot. Errors."</h4>
<p>
Yeah, almost done. Fortunately, Papa handles errors pretty well. The <a href="http://tools.ietf.org/html/rfc4180">CSV standard</a> is somewhat <strike>loose</strike> ambiguous, so Papa tries to consider the edge cases. For example, mismatched fields aren't always the end of the world.
</p>
</div>
<div class="grid-55">
<code class="block"><span class="comment">// Example error:</span>
<section id="errors">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>Error Handling</h4>
<h5>"Aw, shoot. Errors."</h5>
<p>Papa handles errors pretty well. The <a href="http://tools.ietf.org/html/rfc4180">CSV standard</a> is somewhat <strike>loose</strike> ambiguous, so Papa is designed for edge cases. For example, mismatched fields won't break parsing.</p>
<pre><code class="language-javascript">// Example error:
{
type: "FieldMismatch",
code: "TooManyFields",
message: "Expected 3 fields, but parsed 4",
row: 1
}</code>
}</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="jquery">jQuery Plugin</div>
<h4>"Can I use Papa with jQuery?"</h4>
<p>
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 <b>no dependencies</b>.
</p>
</div>
<div class="grid-55">
<code class="block">$("input[type=file]").parse({
<section id="jquery">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>jQuery Plugin</h4>
<h5>"Can I use Papa with jQuery?"</h5>
<p>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 <b>no dependencies</b>.</p>
<pre><code class="language-javascript">$("input[type=file]").parse({
config: {
complete: function(results, file) {
console.log("File done:", file, results);
console.log("This file done:", file, results);
}
},
complete: function() {
console.log("All files done!");
}
});</code>
});</code></pre>
</div>
<div class="clear"></div>
<hr>
</div>
</section>
<div class="grid-40 suffix-5">
<div class="note" id="unparse">JSON to CSV</div>
<h4>"Last thing: what about converting JSON to CSV?"</h4>
<p>
Call <code>unparse()</code> instead of <code>parse()</code>, passing in your array of arrays or array of objects. Papa will figure it out.
</p>
</div>
<div class="grid-55">
<code class="block"><span class="comment">// Output is a properly-formatted CSV string.
// See <a href="/docs#json-to-csv">the docs</a> for more configurability.</span>
var csv = Papa.unparse(yourData);</code>
</div>
<div class="clear"></div>
<hr>
<section id="unparse">
<div class="grid-container narrow-grid">
<div class="grid-100">
<h4>JSON to CSV</h4>
<h5>"Last thing: what about converting JSON to CSV?"</h5>
<p>Call <code>unparse()</code> instead of <code>parse()</code>, passing in your array of arrays or array of objects. Papa will figure it out.</p>
<pre><code class="language-javascript">// Output is a properly-formatted CSV string.
// See <a href="/docs#json-to-csv">the docs</a> for more configurability.
var csv = Papa.unparse(yourData);</code></pre>
</div>
</div>
</section>
<section id="download">
<div class="grid-container">
<div class="grid-100">
<h3 class="text-center">Who's your Papa?</h3>
<h3>Who's Your Papa?</h3>
</div>
<div class="grid-45 suffix-5 mini-papa">
<b><a href="https://github.com/mholt/PapaParse/blob/master/papaparse.min.js">Mini Papa</a></b> for production use
<p>
<b><a href="https://github.com/mholt/PapaParse/blob/master/papaparse.min.js">Lil' Papa</a></b>
(minified) for production use
</p>
</div>
<div class="grid-45 prefix-5">
<b><a href="https://github.com/mholt/PapaParse/blob/master/papaparse.js">Fat Papa</a></b> for debug and development
<p>
<b><a href="https://github.com/mholt/PapaParse/blob/master/papaparse.js">Fat Papa</a></b>
(un-minified) for development
</p>
</div>
<div class="clear"></div>
<div class="grid-100 text-center pad-75">
<div class="grid-100 text-center">
<a href="https://github.com/mholt/PapaParse" class="button">
<i class="fa fa-download"></i>&nbsp; Get Papa Parse on GitHub
<i class="fa fa-github"></i>&nbsp; GitHub
</a>
<a href="/demo" class="button red">
<i class="fa fa-bolt"></i>&nbsp; Try the demo
<i class="fa fa-magic"></i>&nbsp; Demo
</a>
<a href="/docs" class="button gray">
<i class="fa fa-book"></i>&nbsp; Documentation
</a>
</div>
<div class="clear"></div>
</section>
</div>
</main>
<footer>
<!--<div class="footer-top">
<h3>Make Your Papa Proud</h3>
<h4><a href="https://github.com/mholt/PapaParse">Star</a> and <a href="https://github.com/mholt/PapaParse/blob/gh-pages/resources/js/lovers.js">shout</a> if you love #PapaParse</h4>
</div>-->
<div class="footer-main">
<div class="grid-container">
<div class="grid-100 text-center">
&copy; 2013-2014
<div class="grid-40 text-center">
<div class="logo">P</div>
<br><br>
Papa Parse by <a href="https://twitter.com/mholt6">Matt Holt</a>
<br>
Thanks to all <a href="https://github.com/mholt/jquery.parse/graphs/contributors">contributors</a>!
&copy; 2013-2015
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Learn</h5>
<a href="/demo">Demo</a>
<a href="/docs">Documentation</a>
<a href="/faq">FAQ</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Project</h5>
<a href="https://gratipay.com/mholt">Donate</a>
<a href="https://github.com/mholt/PapaParse">GitHub</a>
<a href="https://twitter.com/search?q=%23PapaParse">Share</a>
</div>
<div class="clear hide-on-desktop"></div>
<div class="grid-15 mobile-grid-50 links">
<h5>Download</h5>
<a href="https://github.com/mholt/PapaParse/archive/master.zip">Latest (master)</a>
<hr>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.min.js">Lil' Papa</a>
<a href="https://github.com/mholt/PapaParse/blob/master/papaparse.js">Fat Papa</a>
</div>
<div class="grid-15 mobile-grid-50 links">
<h5>Community</h5>
<a href="https://twitter.com/search?q=%23PapaParse">Twitter</a>
<a href="http://stackoverflow.com/questions/tagged/papaparse">Stack Overflow</a>
</div>
</footer>
</div>
</div>
</footer>
</body>
</html>

370
resources/css/common.css

@ -3,22 +3,25 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb @@ -3,22 +3,25 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
body,
main {
background: #F0F0F0;
background: #FFF;
}
body {
font: 18px/1.5em 'Source Sans Pro', 'Lato', 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 18px;
font: 18px/1.5em 'Source Sans Pro', 'Helvetica Neue', sans-serif;
color: #333;
height: 100%;
}
main {
padding-top: 100px;
}
a {
color: #1D58B1;
}
a:hover {
color: #2D81FF;
color: #2AACFC;
}
b {
@ -29,33 +32,32 @@ i { @@ -29,33 +32,32 @@ i {
font-style: italic;
}
p {
margin: 25px 0;
p,
li {
line-height: 1.75em;
}
small {
font-size: 14px;
p {
margin-bottom: 25px;
}
h1 {
font-family: Arvo;
font-size: 120px;
line-height: 1em;
margin-bottom: 50px;
text-align: center;
small {
font-size: 12px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: Lato, sans-serif;
h5 {
text-align: center;
}
h2,
h3 {
text-align: center;
h1 {
font-family: Lato;
font-weight: 300;
font-size: 40px;
margin-bottom: 50px;
}
h2 {
@ -64,23 +66,34 @@ h2 { @@ -64,23 +66,34 @@ h2 {
}
h3 {
font-size: 34px;
font-weight: bold;
margin: 40px auto 30px;
color: #000;
line-height: 1.25em;
font-size: 48px;
margin-bottom: 30px;
line-height: 1.5em;
}
h4 {
font-size: 20px;
font-weight: 900;
font-size: 28px;
margin-bottom: 50px;
line-height: 1.25em;
}
h5,
footer h4 {
font-size: 12px;
letter-spacing: 2px;
text-transform: uppercase;
color: #A1B2C2; /* darker alternative: #698EB0 */
line-height: 1em;
margin: 50px auto;
}
h3:first-child,
h4:first-child {
margin-top: 15px;
h6 {
font-weight: bold;
text-align: left;
margin: 40px auto 5px;
}
/*
Neat hack! http://css-tricks.com/hash-tag-links-padding/
So when you navigate in-page, the sticky header doesn't cover it up
@ -88,7 +101,8 @@ h4:first-child { @@ -88,7 +101,8 @@ h4:first-child {
h2[id]:before,
h3[id]:before,
h4[id]:before,
.note:before {
h5[id]:before,
h6[id]:before {
display: block;
content: " ";
margin-top: -75px;
@ -96,21 +110,8 @@ h4[id]:before, @@ -96,21 +110,8 @@ h4[id]:before,
visibility: hidden;
}
.note {
color: #AAA;
text-transform: uppercase;
font-size: 12px;
}
ul,
ol {
margin: 30px 0 30px 2em;
}
ul ul,
ol ul,
ol ol,
ul ol {
margin: 0 0 0 2em;
}
@ -122,20 +123,31 @@ ol { @@ -122,20 +123,31 @@ ol {
list-style-type: decimal;
}
header,
main,
footer {
position: relative;
z-index: 1;
}
header,
.insignia {
background: #253C50;
background: #FFF;
border-color: #CCC;
border-style: solid;
box-shadow: 0 -4px 20px -3px rgba(0, 0, 0, 0.2);
}
header {
position: fixed;
top: 0;
width: 100%;
z-index: 1;
border-bottom-width: 1px;
}
main {
padding-top: 100px;
section {
padding: 100px 0;
border-bottom: 1px solid #E3E3E3;
}
main h2 {
@ -145,54 +157,61 @@ main h2 { @@ -145,54 +157,61 @@ main h2 {
margin: 0px 0 50px;
}
main pre {
padding: 10px;
background: #F5F5F5;
}
.text-logo,
.links a {
header .links a {
display: inline-block;
padding: 15px 10px;
color: #FFF;
color: #777;
}
.text-logo {
font-family: Arvo, sans-serif;
letter-spacing: -1px;
color: #1D80AB;
font-size: 24px;
text-decoration: none;
padding: 15px 10px;
}
.text-logo:hover {
color: #66B0E2;
}
.links a {
font-size: 16px;
header .links a {
font-size: 14px;
padding: 15px 25px;
text-decoration: none;
transition: background .2s;
}
.links a:hover {
background: #66B0E2;
header .links a:hover {
color: #000;
}
header .links a:first-child {
padding-left: 10px;
}
.links a .fa {
header .links a .fa {
margin-right: 5px;
}
.donate {
background: #58AA38;
background: #D9FFD1;
}
.donate:hover {
background: #67C941 !important;
}
.ticker .ticker-statement:not(:first-child) {
display: none;
background: #A1FF87 !important;
}
code {
font: 13px/1em 'Liberation Mono', 'Consolas', 'Monaco', 'Menlo', 'Courier New', monospace;
background: #FFF;
font: 75%/1em 'Liberation Mono', 'Consolas', 'Monaco', 'Menlo', 'Courier New', monospace;
color: #000;
padding: 5px;
background: #F5F5F5;
}
h2 code {
@ -200,25 +219,13 @@ h2 code { @@ -200,25 +219,13 @@ h2 code {
background: none;
}
code.block {
color: #000;
padding: 10px;
pre > code {
display: block;
white-space: pre;
overflow-x: auto;
line-height: 1.4em;
margin: 15px auto;
line-height: 1.5em;
font-size: 14px;
tab-size: 4;
}
.grid-55 code {
margin-top: 25px !important;
}
code .comment {
color: #999;
}
.button,
button,
input[type=button],
@ -234,6 +241,7 @@ button[type=submit] { @@ -234,6 +241,7 @@ button[type=submit] {
border-radius: 50px;
cursor: pointer;
outline: none;
line-height: 1.5em;
font-size: 18px;
}
@ -260,7 +268,7 @@ button.red { @@ -260,7 +268,7 @@ button.red {
.button.red:hover,
button.red:hover {
background: #BE1717;
background: #DD2222;
}
.button.green,
@ -273,32 +281,45 @@ button.green:hover { @@ -273,32 +281,45 @@ button.green:hover {
background: #4DB43F;
}
.button.gray,
button.gray {
background: #666;
}
.button.gray:hover,
button.gray:hover {
background: #999;
}
hr {
border: 0;
border-top: 1px solid #D0D0D0;
margin: 35px auto 50px;
}
.clear {
border: 0;
clear: both;
background: 0;
margin: 0;
table {
border-collapse: collapse;
width: 100%;
}
.pad-50 {
padding-top: 50px;
padding-bottom: 50px;
th,
td {
padding: 20px;
font-size: 16px;
border-bottom: 1px solid #E0E0E0;
}
.pad-75 {
padding-top: 75px;
padding-bottom: 75px;
th {
font-weight: bold;
text-align: left;
}
.pad-100 {
padding-top: 100px;
padding-bottom: 100px;
table pre code {
font-size: 12px;
}
table pre,
li pre {
margin: 10px 0;
}
.text-center {
@ -309,49 +330,168 @@ hr { @@ -309,49 +330,168 @@ hr {
text-align: right;
}
.mini-papa {
text-align: right;
footer {
z-index: 0;
background: #263A49;
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
border-bottom: 0;
padding: 0;
font-weight: 300;
font-size: 15px;
color: #EFEFEF;
line-height: 1.5em;
margin-top: 75px;
}
footer a {
color: #EFEFEF;
text-decoration: underline;
}
/*
footer .footer-top {
padding: 20px;
background: #2C4252;
}
*/
footer .footer-main {
font-family: Lato;
padding: 65px 0;
}
footer .links a {
color: #A1B2C2;
text-decoration: none;
transition: color .2s;
display: block;
font-size: 14px;
font-weight: 300;
line-height: 2em;
}
footer .links a:hover {
color: #ACD7FF;
text-decoration: none;
}
footer h3 {
color: #FFF;
font-size: 22px;
margin: 0;
}
footer h4 {
margin: 0;
}
footer h4 a {
color: #A1B2C2;
text-decoration: underline;
}
footer h5 {
color: #FFF;
text-transform: uppercase;
font-size: 16px;
margin: 0 0 10px 0;
font-weight: normal;
text-align: left;
}
footer hr {
border: 0;
border-top: 1px solid #3E5566;
width: 60%;
min-width: 50px;
margin: 10px 0;
}
.logo {
display: inline-block;
color: #263A49;
font-family: Arvo;
font-size: 90px;
line-height: 1em;
background: #EFEFEF;
border-radius: 100px;
padding: 10px 30px;
}
.stuck {
position: fixed;
top: 0;
width: 100%;
border-top-width: 0;
border-bottom-width: 1px;
}
footer {
padding: 25px 0;
background: #333;
color: #DDD;
}
footer a {
color: #CCC;
}
@media (max-width: 1100px) {
.text-logo {
font-size: 16px;
font-size: 18px;
}
p,
li {
line-height: 1.5em;
}
}
@media (max-width: 970px) {
header .links a {
padding: 15px;
}
header > .grid-container,
header .mobile-grid-50 {
padding: 0;
}
}
@media (max-width: 840px) {
header .links a {
font-size: 12px;
}
}
@media (max-width: 767px) {
/* mobile */
p,
li {
line-height: 1.5em;
}
header,
.sticky-wrapper {
position: static;
margin-bottom: 50px !important;
}
main {
padding-top: 0;
header > .grid-container,
header .mobile-grid-50 {
padding: 0;
}
.links a {
section {
padding: 50px 0;
}
header .links a {
font-size: 16px;
display: block;
text-align: left;
padding: 15px 10% !important;
}
main {
padding-top: 0;
}
main h2 {
@ -362,7 +502,13 @@ footer a { @@ -362,7 +502,13 @@ footer a {
font-size: 30px;
}
.mini-papa {
text-align: left;
td,
th {
font-size: 14px;
padding: 10px;
}
footer h5 {
margin-top: 40px;
}
}

123
resources/css/demo.css

@ -1,5 +1,47 @@ @@ -1,5 +1,47 @@
.tabs,
.tab {
border-color: #B4E3FF;
border-style: solid;
}
.tabs {
border-bottom-width: 1px;
padding: 0 5%;
margin-bottom: 30px;
text-align: center;
}
.tab {
display: inline-block;
padding: 8px 20px;
border-bottom-width: 1px;
border-radius: 5px 5px 0 0;
z-index: 2;
cursor: pointer;
font-size: 14px;
color: #777;
background: #FFF;
margin-bottom: -1px;
}
.tab.active {
border-width: 1px;
border-bottom-color: #FFF;
color: #000;
}
.tab:not(.active):hover {
color: #007FB6;
}
label {
display: block;
font-size: 14px;
line-height: 2em;
}
input[type=checkbox] {
margin-right: 4px;
}
textarea,
@ -12,58 +54,61 @@ input[type=email] { @@ -12,58 +54,61 @@ input[type=email] {
tab-size: 4;
}
input[type=text],
input[type=number],
input[type=password],
input[type=email] {
margin: 0 6px;
}
textarea {
box-sizing: border-box;
width: 100%;
height: 350px;
height: 320px;
padding: 10px;
resize: vertical;
}
input[type=file] {
background: #FFF;
padding: 10px;
}
.tab {
padding: 10px 0;
background: #DFDFDF;
font-size: 14px;
margin-bottom: 20px;
cursor: pointer;
color: #555;
dfn {
font-size: 12px;
color: #999;
display: block;
line-height: 1.2em;
margin-bottom: 15px;
}
.tab.active {
background: #333;
color: #FFF;
input[type=checkbox] + dfn {
padding-left: 22px;
}
.tab:not(.active):hover {
background: #C6D8E7;
color: #355A88;
input[type=file],
#url {
margin: 20px auto;
display: block;
}
dfn {
input[type=file] {
padding: 10px;
font-size: 12px;
color: #999;
display: block;
line-height: 1.2em;
border-bottom: 1px solid #CCC;
padding-bottom: 5px;
margin-bottom: 10px;
background: #F0F0F0;
}
#insert-tab {
font-size: 14px;
font-size: 12px;
}
.config {
.input-area {
margin-bottom: 20px;
font-size: 16px;
line-height: 1em;
}
.input-area {
margin-bottom: 40px;
ul {
margin-top: 20px;
}
li {
line-height: 1.5em;
}
#input-local,
@ -85,6 +130,11 @@ dfn { @@ -85,6 +130,11 @@ dfn {
.see-results {
color: #CC0000;
margin-bottom: 20px;
font-size: 12px;
text-transform: uppercase;
letter-spacing: 1px;
line-height: 1.5em;
}
@ -93,4 +143,17 @@ dfn { @@ -93,4 +143,17 @@ dfn {
textarea {
height: 250px;
}
.tab {
border: 0;
background: #F0F0F0;
border-radius: 0;
margin: 10px;
display: block;
}
.tab.active {
background: #3B9CE2;
color: #FFF;
}
}

272
resources/css/home.css

@ -1,37 +1,80 @@ @@ -1,37 +1,80 @@
#top-image {
position: fixed;
width: 100%;
height: 100%;
overflow: hidden;
top: 0;
left: 0;
#top {
padding: 6% 0 8%;
color: #1D80AB;
background: #FFF;
position: relative;
z-index: 0;
background-image: url('../images/papers.jpg');
background-repeat: no-repeat;
background-position: 50% -100px;
background-size: 100% 100%;
/*
For better performance, trigger 3D graphics acceleration.
This reduces lag/jitter considerably, esp. in Chrome.
*/
-webkit-transform: translateZ(0);
-webkit-backface-visibility: hidden;
transform-origin: 100% 100%;
}
.content {
position: relative;
z-index: 1;
#top code {
background: none;
}
#top {
padding: 5% 0;
margin: 0 auto;
color: #FFF;
h1 {
text-align: left;
font-family: Arvo;
font-size: 100px;
line-height: 1em;
margin-top: 8%;
margin-bottom: 40px;
letter-spacing: -5px;
}
h2 {
font-size: 24px;
text-align: left;
margin-bottom: 50px;
}
/* Switch around h4 and h5 for homepage... */
h4 {
font-size: 12px;
letter-spacing: 2px;
margin-bottom: 10px;
text-transform: uppercase;
color: #A1B2C2;
line-height: 1em;
}
h5 {
font-size: 28px;
margin-bottom: 50px;
line-height: 1.25em;
text-transform: none;
color: inherit;
letter-spacing: 0;
margin-top: 0;
}
#title-main {
float: left;
}
#title-code {
float: right;
}
text-shadow: 0 2px 1px rgba(0, 0, 0, .7);
background: rgba(0, 0, 0, .4);
max-width: 1200px;
box-shadow: 0 0 80px 50px rgba(0, 0, 0, .4);
main {
padding-top: 0;
}
#top h2 {
margin-bottom: 90px;
font-size: 42px;
.fa-heart {
color: #F00;
}
header {
border-top-width: 1px;
}
header,
@ -44,6 +87,9 @@ header, @@ -44,6 +87,9 @@ header,
margin-bottom: -150px;
}
header .fa-heart {
color: inherit;
}
.insignia {
display: block;
@ -53,137 +99,148 @@ header, @@ -53,137 +99,148 @@ header,
border-radius: 50%;
margin: 0 auto;
text-align: center;
font: 170px/250px Arvo, sans-serif;
text-shadow: 0 3px 2px rgba(0, 0, 0, .5);
color: #FFF;
color: #1D80AB;
z-index: 2;
margin-bottom: 30px;
border-width: 1px;
}
main {
padding-top: 0;
box-shadow: 0 -2px 15px rgba(0, 0, 0, .5);
}
.firefox-hack {
#version-intro {
position: absolute;
font-size: 12px;
top: 18%;
width: 100%;
font-family: 'Source Sans Pro', sans-serif;
text-transform: uppercase;
letter-spacing: 2px;
}
h3 {
text-align: left;
#version {
text-shadow: 0 3px 2px rgba(169, 169, 169, 0.5);
font: 100px/250px Arvo, sans-serif;
}
.showcase {
text-align: left;
margin-bottom: 40px;
background: #1D2933;
clear: both;
}
.showcase a {
color: #668B99;
.firefox-hack {
position: absolute;
width: 100%;
}
.showcase-title {
color: #FFF;
font-size: 14px;
text-transform: uppercase;
padding: 10px 0;
background: #2C4252;
text-align: center;
.lover {
margin-bottom: 0;
}
.showcase .fa-heart {
color: #F00;
margin: 0 2px;
.grid-container.narrow-grid {
max-width: 850px;
}
.showcase-image img {
width: 90%;
vertical-align: middle;
.mini-papa {
text-align: right;
}
.showcase-image .fa-plus {
padding: 20px 35px;
border: 4px dashed #2C4252;
#ticker {
width: 90%;
max-width: 800px;
margin: 0 auto;
height: 80px;
position: relative;
}
.showcase-image {
width: 200px;
height: 100px;
line-height: 100px;
.ticker-item {
font-size: 24px;
color: #565656;
text-align: center;
display: inline-block;
transition: background .4s;
}
.showcase-image:hover {
background: #375A77; /* default */
font-family: Lato;
font-weight: 300;
line-height: 1.25em;
width: 100%;
position: absolute;
top: 0;
transition: transform .25s;
transform: scale(0);
}
.showcase-image.smartystreets:hover {
background: #FFC200;
.ticker-item.current {
transform: scale(1);
}
.showcase-image.maxcdn:hover {
background: #F37121;
.add-lover-link {
text-decoration: none;
}
.showcase-image.maxcdn img {
width: auto;
max-height: 20px;
footer {
margin-top: 0;
}
@media (max-width: 1150px) {
#title-main h1 {
font-size: 85px;
}
#title-main h2 {
font-size: 20px;
margin-bottom: 30px;
}
#title-code code {
font-size: 12px;
}
button,
.button {
padding: 8px 20px;
font-size: 14px;
}
.showcase-add {
display: none;
color: #DDD;
padding: 10px 0;
font-size: 16px;
text-align: center;
border-top: 1px solid #337BAC;
}
@media (max-width: 900px) {
header,
.sticky-wrapper {
margin-bottom: -120px;
}
.insignia {
font-size: 100px;
width: 175px;
height: 175px;
}
#version {
font-size: 70px;
line-height: 175px;
}
}
@media (max-width: 950px) {
#title-code {
display: none;
}
#top {
padding-top: 0;
}
@media (max-width: 767px) {
/* mobile */
#title-main,
#title-main h1,
#title-main h2 {
width: 100%;
text-align: center;
}
#top-image {
background-position: 50% 50%;
background-size: auto 100%;
#title-main {
padding-bottom: 50px;
}
}
@media (max-width: 767px) {
/* mobile */
#top h2 {
margin-bottom: 20px;
}
#title-main {
padding-bottom: 10px;
}
.stuck {
position: static;
}
@ -192,14 +249,15 @@ h3 { @@ -192,14 +249,15 @@ h3 {
display: none;
}
#ticker {
height: 120px;
}
.showcase-image {
width: 49%;
.lover {
margin-bottom: 25px;
}
.showcase img {
max-width: 200px;
.mini-papa {
text-align: left;
}
}

93
resources/css/tomorrow.highlight.css

@ -0,0 +1,93 @@ @@ -0,0 +1,93 @@
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
/* Tomorrow Comment */
.hljs-comment {
color: #8e908c;
}
/* Tomorrow Red */
.hljs-variable,
.hljs-attribute,
.hljs-tag,
.hljs-regexp,
.ruby .hljs-constant,
.xml .hljs-tag .hljs-title,
.xml .hljs-pi,
.xml .hljs-doctype,
.html .hljs-doctype,
.css .hljs-id,
.css .hljs-class,
.css .hljs-pseudo {
color: #c82829;
}
/* Tomorrow Orange */
.hljs-number,
.hljs-preprocessor,
.hljs-pragma,
.hljs-built_in,
.hljs-literal,
.hljs-params,
.hljs-constant {
color: #f5871f;
}
/* Tomorrow Yellow */
.ruby .hljs-class .hljs-title,
.css .hljs-rules .hljs-attribute {
color: #eab700;
}
/* Tomorrow Green */
.hljs-string,
.hljs-value,
.hljs-inheritance,
.hljs-header,
.ruby .hljs-symbol,
.xml .hljs-cdata {
color: #718c00;
}
/* Tomorrow Aqua */
.css .hljs-hexcolor {
color: #3e999f;
}
/* Tomorrow Blue */
.hljs-function,
.python .hljs-decorator,
.python .hljs-title,
.ruby .hljs-function .hljs-title,
.ruby .hljs-title .hljs-keyword,
.perl .hljs-sub,
.javascript .hljs-title,
.coffeescript .hljs-title {
color: #4271ae;
}
/* Tomorrow Purple */
.hljs-keyword,
.javascript .hljs-function {
color: #8959a8;
}
.hljs {
display: block;
overflow-x: auto;
/*background: white;
padding: 0.5em;*/
color: #4d4d4c;
-webkit-text-size-adjust: none;
}
.coffeescript .javascript,
.javascript .xml,
.tex .hljs-formula,
.xml .javascript,
.xml .vbscript,
.xml .css,
.xml .hljs-cdata {
opacity: 0.5;
}

12
resources/js/common.js

@ -1,12 +1,8 @@ @@ -1,12 +1,8 @@
$(function()
// Returns a random number between min and max (inclusive)
function randomInt(min, max)
{
});
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// BEGIN GOOGLE ANALYTICS

1
resources/js/highlight.min.js vendored

File diff suppressed because one or more lines are too long

54
resources/js/home.js

File diff suppressed because one or more lines are too long

52
resources/js/lovers.js

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
/**
INSTRUCTIONS
If you use Papa Parse, add your site/project/company to the list
below. Here is a description of the fields:
link: (optional) The URL to your web site
name: The name of the site/project/company
description: Say why Papa Parse is important to your
application. The name is prepended to this
description when rendered. Make sure that it
reads as a fluid sentence when the name is
concatenated with the description.
quote: (optional) A short testimonial of what you think
of Papa Parse.
Note that the name and description are required. Please
use English and keep the length similar to existing entries;
entries that are too long or extremely short should be
edited before being accepted.
Thanks for being a part of Papa Parse!
**/
var peopleLovePapa = [
{
link: "https://smartystreets.com",
name: "SmartyStreets",
description: "verifies addresses, many of which are submitted in CSV files. Papa Parse can process files with over a million addresses in the browser.",
quote: "Because of Papa Parse, we rapidly built an awesome client-side list processing service."
},
{
link: "http://jannah.github.io/MetaReader",
name: "MetaReader",
description: "helps you see your data from a meta perspective before you start detailed analysis.",
quote: "Papa Parse made it very easy to load and ready user CSV files in the browser on the client side."
},
{
link: "https://github.com/JamesJansson/EpiML",
name: "EpiML",
description: "is an agent-based mathematical model for the web, still in its early stages of development.",
quote: "Papa makes it so easy to use CSV, which is good for scientists."
},
{
link: "https://wikipedia.org",
name: "Wikipedia",
description: "uses Papa Parse in VisualEditor to help article editors effortlessly build data tables from text files."
}
];

2
resources/js/skrollr.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save