Browse Source

Add config option to convert headers to lowercase

pull/540/head
Nikola Telkedzhiev 7 years ago
parent
commit
fe16b11dd3
  1. 4
      papaparse.js
  2. 9
      tests/test-cases.js

4
papaparse.js

@ -1113,6 +1113,10 @@ @@ -1113,6 +1113,10 @@
header = header.trim();
}
if (_config.lowercaseHeaders) {
header = header.toLowerCase();
}
_fields.push(header);
}
_results.data.splice(0, 1);

9
tests/test-cases.js

@ -733,6 +733,15 @@ var PARSE_TESTS = [ @@ -733,6 +733,15 @@ var PARSE_TESTS = [
errors: []
}
},
{
description: "Header rows are lowercase when lowercaseHeader is set",
input: 'A,b\r\na,b',
config: { header: true, lowercaseHeaders: true },
expected: {
data: [{"a": "a", "b": "b"}],
errors: []
}
},
{
description: "Line ends with quoted field, first field of next line is empty using headers",
input: 'a,b,"c"\r\nd,e,"f"\r\n,"h","i"\r\n,"k","l"',

Loading…
Cancel
Save