From 8f3f41b7c75580434dd3ee0e151f5b7cf1fcbd7e Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 2 Feb 2015 14:44:08 -0700 Subject: [PATCH] Allow multiple-char delimiters (closes #160) --- papaparse.js | 1 - player/player.html | 2 +- tests/test-cases.js | 13 +++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/papaparse.js b/papaparse.js index fc8b91a..d9bc550 100644 --- a/papaparse.js +++ b/papaparse.js @@ -925,7 +925,6 @@ // Delimiter must be valid if (typeof delim !== 'string' - || delim.length != 1 || Papa.BAD_DELIMITERS.indexOf(delim) > -1) delim = ","; diff --git a/player/player.html b/player/player.html index 38dc32a..90b22f4 100644 --- a/player/player.html +++ b/player/player.html @@ -25,7 +25,7 @@ - + Line Endings: diff --git a/tests/test-cases.js b/tests/test-cases.js index 5e2ae14..66147a0 100644 --- a/tests/test-cases.js +++ b/tests/test-cases.js @@ -563,15 +563,24 @@ var PARSE_TESTS = [ } }, { - description: "Bad delimiter", + description: "Bad delimiter (\\n)", input: 'a,b,c', - config: { delimiter: "DELIM" }, + config: { delimiter: "\n" }, notes: "Should silently default to comma", expected: { data: [['a', 'b', 'c']], errors: [] } }, + { + description: "Multi-character delimiter", + input: 'a, b, c', + config: { delimiter: ", " }, + expected: { + data: [['a', 'b', 'c']], + errors: [] + } + }, { description: "Dynamic typing converts numeric literals", input: '1,2.2,1e3\r\n-4,-4.5,-4e-5\r\n-,5a,5-2',