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. 10
      jquery.parse.js
  2. 4
      jquery.parse.min.js
  3. 4
      parse.jquery.json
  4. 13
      tests.js

10
jquery.parse.js

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

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 @@ @@ -1,8 +1,8 @@
{
"name": "parse",
"version": "2.0.3",
"version": "2.0.4",
"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": [
"csv",
"parse",

13
tests.js

@ -144,6 +144,10 @@ var tests = [ @@ -144,6 +144,10 @@ var tests = [
input: "F1,F2,F3\r\n \r\nV1,2,V3",
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",
cases: [
@ -537,7 +541,14 @@ $(function() @@ -537,7 +541,14 @@ $(function()
function doTest(input, config)
{
return $.parse(input, config);
// try
// {
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)

Loading…
Cancel
Save