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.
That's what streaming is for. Just 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.
Oh. Yeah, that happens when a long-running script is executing in the same thread. Use a <ahref="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>
<divclass="grid-55">
<codeclass="block">Papa.parse(bigFile, {
worker: true,
step: function(row) {
console.log("Row:", row.data);
},
complete: function() {
console.log("All done!");
}
});</code>
</div>
<divclass="clear"></div>
<hr>
<divclass="grid-40 suffix-5">
<divclass="note"id="header">Header Rows</div>
<h4>"Rad! What if I want data keyed by field name?"</h4>
<p>
All you have to do is tell Papa that there is a header row. This is a convenience, however, which comes at a slight performance cost, negligible for most inputs.
</p>
</div>
<divclass="grid-55">
<codeclass="block"><spanclass="comment">// Key data by field name instead of index/position</span>
<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 the number and boolean types, respectively.
</p>
</div>
<divclass="grid-55">
<codeclass="block"><spanclass="comment">// All parsed data is normally returned as a string.
<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>
<divclass="grid-55">
<codeclass="block"><spanclass="comment">// Mostly found in academia, some CSV files
// may have commented lines in them</span>
var results = Papa.parse(csv, {
comments: "#"
});</code>
</div>
<divclass="clear"></div>
<hr>
<divclass="grid-40 suffix-5">
<divclass="note"id="errors">Error handling</div>
<h4>"Are we done yet? I'm—aw, shoot. Errors."</h4>
<p>
(Almost done!) Fortunately, Papa can handle errors pretty well. The <ahref="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, unescaped quotes aren't always the end of the world.
</p>
</div>
<divclass="grid-55">
<codeclass="block"><spanclass="comment">// Errors are returned with results. Always. Example:
/*
{
type: "Quotes",
code: "UnexpectedQuotes",
message: "Unexpected quotes",
line: 2,
row: 1,
index: 83
}
*/</span></code>
</div>
<divclass="clear"></div>
<hr>
<divclass="grid-40 suffix-5">
<divclass="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>.