Browse Source

Using latest; better file error handling

pull/89/head
Matthew Holt 11 years ago
parent
commit
edde8bf77a
  1. 6
      docs.html
  2. 4
      resources/js/demo.js
  3. 5
      resources/js/papaparse.js

6
docs.html

@ -317,6 +317,7 @@ var csv = Papa.unparse({
worker: false, worker: false,
comments: false, comments: false,
complete: undefined, complete: undefined,
error: undefined,
download: false, download: false,
keepEmptyRows: false, keepEmptyRows: false,
chunk: undefined chunk: undefined
@ -349,8 +350,9 @@ var csv = Papa.unparse({
</code> </code>
If streaming, results will <i>not</i> be available in this function. If streaming, results will <i>not</i> be available in this function.
</li> </li>
<li><code>download</code> If <code>true</code>, this indicates that the string you passed in is actually a URL from which to download a file and parse it.</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>keepEmptyRows</code> If <code>true</code>, rows that are empty will be included in the results as an empty array. This is useful if you want to maintain line (or at least <i>row</i>) parity with the original input.</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>keepEmptyRows</code> If true, rows that are empty will be included in the results as an empty array. This is useful if you want to maintain line (or at least <i>row</i>) parity with the original input.</li>
<li><code>chunk</code> A callback, much like step, which activates streaming and is executed after every chunk (piece) is loaded and parsed. Works only with local and remote files. Do not use both chunk and step callbacks together. This function can be used to receive results one chunk at a time rather than one row at a time. If your file has a million rows, this results in, say, 10,000 function invocations rather than 1,000,000. In some cases, this may be faster.</li> <li><code>chunk</code> A callback, much like step, which activates streaming and is executed after every chunk (piece) is loaded and parsed. Works only with local and remote files. Do not use both chunk and step callbacks together. This function can be used to receive results one chunk at a time rather than one row at a time. If your file has a million rows, this results in, say, 10,000 function invocations rather than 1,000,000. In some cases, this may be faster.</li>
</ul> </ul>
</div> </div>

4
resources/js/demo.js

@ -238,10 +238,10 @@ function completeFn(results)
setTimeout(enableButton, 100); setTimeout(enableButton, 100);
} }
function errorFn(err) function errorFn(err, file)
{ {
end = now(); end = now();
console.log("ERROR:", err); console.log("ERROR:", err, file);
enableButton(); enableButton();
} }

5
resources/js/papaparse.js

@ -221,6 +221,11 @@
if (isFunction(config.complete)) if (isFunction(config.complete))
config.complete(results); config.complete(results);
}; };
reader.onerror = function()
{
if (isFunction(config.error))
config.error(reader.error, _input);
};
reader.readAsText(_input, config.encoding); reader.readAsText(_input, config.encoding);
} }
} }

Loading…
Cancel
Save