Browse Source

Preview count now adds 1 if using header row (fixes #77)

pull/93/head
Matthew Holt 11 years ago
parent
commit
e4ed3b54ac
  1. 2
      papaparse.js
  2. 10
      tests/test-cases.js

2
papaparse.js

@ -709,6 +709,8 @@ @@ -709,6 +709,8 @@
_results = new Parser(_config).parse(input);
return processResults();
if (_config.preview && _config.header)
_config.preview++; // to compensate for header row
};
function processResults()

10
tests/test-cases.js

@ -413,6 +413,16 @@ var PARSE_TESTS = [ @@ -413,6 +413,16 @@ var PARSE_TESTS = [
errors: []
}
},
{
description: "Preview with header row",
notes: "Preview is defined to be number of rows of input not including header row",
input: 'a,b,c\r\nd,e,f\r\ng,h,i\r\nj,k,l',
config: { header: true, preview: 2 },
expected: {
data: [{"a": "d", "b": "e", "c": "f"}, {"a": "g", "b": "h", "c": "i"}],
errors: []
}
},
{
description: "Keep empty rows",
input: 'a,b,c\r\n\r\nd,e,f',

Loading…
Cancel
Save