Browse Source

Resolve parsing issue when first field is empty and unquoted (#696)

pull/702/head
David Boskovic 6 years ago committed by Sergi Almacellas Abellana
parent
commit
d5e2fae859
  1. 2
      papaparse.js
  2. 8
      tests/test-cases.js

2
papaparse.js

@ -1608,7 +1608,7 @@ License: MIT
var nextDelimObj = getNextUnqotedDelimiter(nextDelim, quoteSearch, nextNewline); var nextDelimObj = getNextUnqotedDelimiter(nextDelim, quoteSearch, nextNewline);
// if we have next delimiter char which is not enclosed in quotes // if we have next delimiter char which is not enclosed in quotes
if (nextDelimObj && nextDelimObj.nextDelim) { if (nextDelimObj && typeof nextDelimObj.nextDelim !== 'undefined') {
nextDelim = nextDelimObj.nextDelim; nextDelim = nextDelimObj.nextDelim;
quoteSearch = nextDelimObj.quoteSearch; quoteSearch = nextDelimObj.quoteSearch;
row.push(input.substring(cursor, nextDelim)); row.push(input.substring(cursor, nextDelim));

8
tests/test-cases.js

@ -323,6 +323,14 @@ var CORE_PARSER_TESTS = [
errors: [] errors: []
} }
}, },
{
description: "Line starts with unquoted empty field",
input: ',b,c\n"d",e,f',
expected: {
data: [['', 'b', 'c'], ['d', 'e', 'f']],
errors: []
}
},
{ {
description: "Line ends with quoted field", description: "Line ends with quoted field",
input: 'a,b,c\nd,e,f\n"g","h","i"\n"j","k","l"', input: 'a,b,c\nd,e,f\n"g","h","i"\n"j","k","l"',

Loading…
Cancel
Save