Browse Source

Allow multiple-char delimiters (closes #160)

pull/181/head
Matthew Holt 10 years ago
parent
commit
8f3f41b7c7
  1. 1
      papaparse.js
  2. 2
      player/player.html
  3. 13
      tests/test-cases.js

1
papaparse.js

@ -925,7 +925,6 @@ @@ -925,7 +925,6 @@
// Delimiter must be valid
if (typeof delim !== 'string'
|| delim.length != 1
|| Papa.BAD_DELIMITERS.indexOf(delim) > -1)
delim = ",";

2
player/player.html

@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
<label><input type="checkbox" id="step-pause"> Pause on step</label>
<label><input type="checkbox" id="print-steps"> Log each step/chunk</label>
<label>Delimiter: <input type="text" size="5" maxlength="1" placeholder="auto" id="delimiter"> <a href="javascript:" id="insert-tab">tab</a></label>
<label>Delimiter: <input type="text" size="5" placeholder="auto" id="delimiter"> <a href="javascript:" id="insert-tab">tab</a></label>
Line Endings:

13
tests/test-cases.js

@ -563,15 +563,24 @@ var PARSE_TESTS = [ @@ -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',

Loading…
Cancel
Save