Browse Source

Merge branch 'fix-delimeter-handling' of https://github.com/jseter/PapaParse into strict-quoting-flag

pull/730/head
Jamie Seter 5 years ago
parent
commit
c3493f4d7a
  1. 6
      papaparse.js
  2. 16
      tests/test-cases.js

6
papaparse.js

@ -1539,6 +1539,12 @@ License: MIT
continue; continue;
} }
if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
nextDelim = input.indexOf(delim, (quoteSearch + 1));
}
if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
nextNewline = input.indexOf(newline, (quoteSearch + 1));
}
// Check up to nextDelim or nextNewline, whichever is closest // Check up to nextDelim or nextNewline, whichever is closest
var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline); var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo); var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);

16
tests/test-cases.js

@ -1464,6 +1464,22 @@ var PARSE_TESTS = [
data: [['a', 'b'], ['c', 'd'], [' , ', ','], ['" "', '""']], data: [['a', 'b'], ['c', 'd'], [' , ', ','], ['" "', '""']],
errors: [] errors: []
} }
},
{
description: "Quoted fields with spaces between closing quote and next delimiter and contains delimiter",
input: 'A,",B" ,C,D\nE,F,G,H',
expected: {
data: [['A', ',B', 'C', 'D'],['E', 'F', 'G', 'H']],
errors: []
}
},
{
description: "Quoted fields with spaces between closing quote and newline and contains newline",
input: 'a,b,"c\n" \nd,e,f',
expected: {
data: [['a', 'b', 'c\n'], ['d', 'e', 'f']],
errors: []
}
} }
]; ];

Loading…
Cancel
Save