Browse Source

Fix for empty first line of input (closes #30)

pull/33/head 2.0.4
Matthew Holt 11 years ago
parent
commit
2194d2d76b
  1. 6
      jquery.parse.js
  2. 4
      jquery.parse.min.js
  3. 4
      parse.jquery.json
  4. 11
      tests.js

6
jquery.parse.js

@ -1,6 +1,6 @@
/* /*
Papa Parse Papa Parse
v2.0.3 v2.0.4
https://github.com/mholt/jquery.parse https://github.com/mholt/jquery.parse
*/ */
@ -436,7 +436,7 @@
if (_config.header) if (_config.header)
{ {
if (_state.lineNum == 1 && _invocations == 1) if (_state.lineNum == 1 && _invocations == 1)
_state.parsed.fields.push(_state.fieldVal) _state.parsed.fields.push(_state.fieldVal);
else else
{ {
var currentRow = _state.parsed.rows[_state.parsed.rows.length - 1]; var currentRow = _state.parsed.rows[_state.parsed.rows.length - 1];
@ -487,7 +487,7 @@
{ {
if (streaming()) if (streaming())
_state.parsed = [ [] ]; _state.parsed = [ [] ];
else else if (!_config.header)
_state.parsed.push([]); _state.parsed.push([]);
} }

4
jquery.parse.min.js vendored

File diff suppressed because one or more lines are too long

4
parse.jquery.json

@ -1,8 +1,8 @@
{ {
"name": "parse", "name": "parse",
"version": "2.0.3", "version": "2.0.4",
"title": "Papa Parse", "title": "Papa Parse",
"description": "Papa is a powerful CSV (delimited text) parser that streams handles large files and gracefully handles malformed input.", "description": "Papa is a powerful CSV (delimited text) parser that streams large files and gracefully handles malformed input.",
"keywords": [ "keywords": [
"csv", "csv",
"parse", "parse",

11
tests.js

@ -144,6 +144,10 @@ var tests = [
input: "F1,F2,F3\r\n \r\nV1,2,V3", input: "F1,F2,F3\r\n \r\nV1,2,V3",
cases: resultSet1 cases: resultSet1
}, },
{
input: "\r\nF1,F2,F3\r\n \r\nV1,2,V3",
cases: resultSet1
},
{ {
input: "F1,F2,F3\nV1,2,V3\nV4,V5,V6", input: "F1,F2,F3\nV1,2,V3\nV4,V5,V6",
cases: [ cases: [
@ -537,7 +541,14 @@ $(function()
function doTest(input, config) function doTest(input, config)
{ {
// try
// {
return $.parse(input, config); return $.parse(input, config);
// }
// catch (e)
// {
// return {exception: e.message, error: e, note: "See console to inspect stack"};
// }
} }
function render(input, expected, actual, config, count, status) function render(input, expected, actual, config, count, status)

Loading…
Cancel
Save