7368a48d12
e11ee26581
@ -1330,7 +1330,7 @@ License: MIT
avgFieldCount /= (preview.data.length - emptyLinesCount);
if ((typeof bestDelta === 'undefined' || delta <= bestDelta)
&& (typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
&& ((typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) || delta < bestDelta) && avgFieldCount > 1.99) {
bestDelta = delta;
bestDelim = delim;
maxFieldCount = avgFieldCount;
@ -2629,6 +2629,14 @@ var CUSTOM_TESTS = [
var results = Papa.parse('"A","B","C","D"');
callback(results.meta.delimiter);
}
},
{
description: "Should correctly guess default delimiters when other sign is used more often but not right delimiter.",
expected: ";",
run: function(callback) {
var results = Papa.parse('ID;comment;geom\n1;HiThere;POLYGON(2 3, 3 4, 5 6, 4 5, 4 3, 2 3)\n2;HowAreYou;POLYGON(2 3, 3 4, 5 6, 4 5, 4 3, 2 3)\n3;WhatsUp;POLYGON(2 3, 3 4, 5 6, 4 5, 4 3, 2 3)\n4;Sunday;POLYGON(2 3, 3 4, 5 6, 4 5, 4 3, 2 3)');
];