Browse Source

Now auto-detecting ASCII 30 and ASCII 31 char delimiters

pull/37/head
Matthew Holt 11 years ago
parent
commit
df15814a38
  1. 6
      jquery.parse.js
  2. 4
      jquery.parse.min.js
  3. 61
      tests.js

6
jquery.parse.js

@ -1,6 +1,6 @@
/* /*
Papa Parse Papa Parse
v2.0.6 v2.0.7
https://github.com/mholt/jquery.parse https://github.com/mholt/jquery.parse
*/ */
@ -310,7 +310,9 @@
function guessDelimiter(input) function guessDelimiter(input)
{ {
var delimiters = [",", "\t", "|", ";"]; var recordSep = String.fromCharCode(30);
var unitSep = String.fromCharCode(31);
var delimiters = [",", "\t", "|", ";", recordSep, unitSep];
var bestDelim, bestDelta, fieldCountPrevRow; var bestDelim, bestDelta, fieldCountPrevRow;
for (var i in delimiters) for (var i in delimiters)

4
jquery.parse.min.js vendored

File diff suppressed because one or more lines are too long

61
tests.js

@ -1,6 +1,9 @@
var passCount = 0, failCount = 0; var passCount = 0, failCount = 0;
var passing = "passing"; var passing = "passing";
var failing = "failing" var failing = "failing";
var recordSep = String.fromCharCode(30);
var unitSep = String.fromCharCode(31);
var resultSet1 = [ var resultSet1 = [
{ {
@ -145,7 +148,7 @@ var tests = [
cases: resultSet1 cases: resultSet1
}, },
{ {
input: "\r\nF1,F2,F3\r\n \r\nV1,2,V3", input: "\r\nF1,F2,F3\r\nV1,2,V3",
cases: resultSet1 cases: resultSet1
}, },
{ {
@ -464,8 +467,8 @@ var tests = [
] ]
}, },
"errors": { "errors": {
"length": 0 "length": 0
} }
} }
} }
] ]
@ -509,6 +512,56 @@ var tests = [
} }
} }
] ]
},
{
input: ["F1","F2","F3\r\nV1","V2","V3"].join(recordSep),
cases: [
{
config: { delimiter: "", header: false, dynamicTyping: false },
expected: {
"results": [
[
"F1",
"F2",
"F3"
],
[
"V1",
"V2",
"V3"
],
],
"errors": {
"length": 0
}
}
}
]
},
{
input: ["F1","F2","F3\r\nV1","V2","V3"].join(unitSep),
cases: [
{
config: { delimiter: "", header: false, dynamicTyping: false },
expected: {
"results": [
[
"F1",
"F2",
"F3"
],
[
"V1",
"V2",
"V3"
],
],
"errors": {
"length": 0
}
}
}
]
} }
]; ];

Loading…
Cancel
Save