Browse Source

Fixed code indentation

pull/180/head
Matthew Holt 10 years ago
parent
commit
281f591475
  1. 58
      index.html

58
index.html

@ -39,25 +39,25 @@ @@ -39,25 +39,25 @@
<div id="title-code">
<pre><code class="language-javascript">// Parse CSV string
var data = Papa.parse(csv);
var data = Papa.parse(csv);
// Convert back to CSV
var csv = Papa.unparse(data);
// Convert back to CSV
var csv = Papa.unparse(data);
// Parse local CSV file
Papa.parse(file, {
// Parse local CSV file
Papa.parse(file, {
complete: function(results) {
console.log("Finished:", results.data);
}
});
});
// Stream big file in worker thread
Papa.parse(bigFile, {
// Stream big file in worker thread
Papa.parse(bigFile, {
worker: true,
step: function(results) {
console.log("Row:", results.data);
}
});</code></pre>
});</code></pre>
</div>
</div>
</div>
@ -212,13 +212,13 @@ @@ -212,13 +212,13 @@
<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
}
*/</code></pre>
*/</code></pre>
</div>
</div>
</section>
@ -234,8 +234,8 @@ @@ -234,8 +234,8 @@
<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>
console.log(results.meta.delimiter);
// "\t"</code></pre>
</div>
</div>
</section>
@ -254,7 +254,7 @@ @@ -254,7 +254,7 @@
complete: function(results) {
console.log(results);
}
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -276,7 +276,7 @@ @@ -276,7 +276,7 @@
complete: function(results) {
console.log(results);
}
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -303,7 +303,7 @@ @@ -303,7 +303,7 @@
complete: function() {
console.log("All done!");
}
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -326,7 +326,7 @@ @@ -326,7 +326,7 @@
complete: function() {
console.log("All done!");
}
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -343,9 +343,9 @@ @@ -343,9 +343,9 @@
<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, {
var results = Papa.parse(csv, {
header: true
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -362,9 +362,9 @@ @@ -362,9 +362,9 @@
<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, {
var results = Papa.parse(csv, {
dynamicTyping: true
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -383,10 +383,10 @@ @@ -383,10 +383,10 @@
<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, {
// may have commented lines in them
var results = Papa.parse(csv, {
comments: "#"
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -404,12 +404,12 @@ @@ -404,12 +404,12 @@
<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></pre>
}</code></pre>
</div>
</div>
</section>
@ -434,7 +434,7 @@ @@ -434,7 +434,7 @@
complete: function() {
console.log("All files done!");
}
});</code></pre>
});</code></pre>
</div>
</div>
</section>
@ -451,8 +451,8 @@ @@ -451,8 +451,8 @@
<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>
// See <a href="/docs#json-to-csv">the docs</a> for more configurability.
var csv = Papa.unparse(yourData);</code></pre>
</div>
</div>
</section>

Loading…
Cancel
Save