Browse Source

Merge pull request #318 from mickylad/delimiter-callback

Add callback option for specifying delimiter.
pull/325/merge
Sergi Almacellas Abellana 8 years ago committed by GitHub
parent
commit
449972eb65
  1. 5
      papaparse.js
  2. 9
      tests/test-cases.js

5
papaparse.js

@ -771,6 +771,11 @@ @@ -771,6 +771,11 @@
}
_results.meta.delimiter = _config.delimiter;
}
else if(typeof _config.delimiter === 'function')
{
_config.delimiter = _config.delimiter(input);
_results.meta.delimiter = _config.delimiter;
}
var parserConfig = copy(_config);
if (_config.preview && _config.header)

9
tests/test-cases.js

@ -625,6 +625,15 @@ var PARSE_TESTS = [ @@ -625,6 +625,15 @@ var PARSE_TESTS = [
errors: []
}
},
{
description: "Callback delimiter",
input: 'a$ b$ c',
config: { delimiter: function(input) { return input[1] + ' '; } },
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