Browse Source

Merge pull request #281 from lschjeide/master

Fixes auto detecting mixed line endings
pull/301/head
Matt Holt 9 years ago
parent
commit
a61e4a3153
  1. 6
      papaparse.js
  2. 8
      tests/test-cases.js

6
papaparse.js

@ -950,7 +950,11 @@ @@ -950,7 +950,11 @@
var r = input.split('\r');
if (r.length === 1)
var n = input.split('\n');
var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
if (r.length === 1 || nAppearsFirst)
return '\n';
var numWithN = 0;

8
tests/test-cases.js

@ -507,6 +507,14 @@ var PARSE_TESTS = [ @@ -507,6 +507,14 @@ var PARSE_TESTS = [
errors: []
}
},
{
description: "Mixed slash n and slash r should choose first as precident",
input: 'a,b,c\nd,e,f\rg,h,i\n',
expected: {
data: [['a', 'b', 'c'], ['d', 'e', 'f\rg', 'h', 'i'], ['']],
errors: []
}
},
{
description: "Header row with one row of data",
input: 'A,B,C\r\na,b,c',

Loading…
Cancel
Save