Browse Source

Minor fix for some quotes; new test cases

pull/124/head 4.0.2
Matthew Holt 10 years ago
parent
commit
a126dd250e
  1. 2
      bower.json
  2. 2
      package.json
  3. 14
      papaparse.js
  4. 4
      papaparse.min.js
  5. 2
      parse.jquery.json
  6. 16
      tests/test-cases.js

2
bower.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "Papa-Parse",
"version": "4.0.1",
"version": "4.0.2",
"main": "papaparse.js",
"homepage": "http://papaparse.com",
"authors": [

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "papaparse",
"version": "4.0.1",
"version": "4.0.2",
"description": "Fast and powerful CSV parser for the browser that supports web workers and streaming large files. Converts CSV to JSON and JSON to CSV.",
"keywords": [
"csv",

14
papaparse.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
Papa Parse
v4.0.1
v4.0.2
https://github.com/mholt/PapaParse
*/
(function(global)
@ -1187,7 +1187,8 @@ @@ -1187,7 +1187,8 @@
if (input.substr(quoteSearch+1, newlineLen) == newline && hasCloseQuote(input.substring(cursor, quoteSearch+1)))
{
// Closing quote followed by newline
saveRow(quoteSearch, quoteSearch + 1 + newlineLen);
row.push(input.substring(cursor, quoteSearch).replace(/""/g, '"'));
saveRow(quoteSearch + 1 + newlineLen);
if (stepIsFunction)
{
@ -1229,7 +1230,8 @@ @@ -1229,7 +1230,8 @@
// End of row
if (nextNewline != -1)
{
saveRow(nextNewline, nextNewline + newlineLen);
row.push(input.substring(cursor, nextNewline));
saveRow(nextNewline + newlineLen);
if (stepIsFunction)
{
@ -1263,14 +1265,12 @@ @@ -1263,14 +1265,12 @@
return returnable();
}
// Appends input from cursor to fromCursorToHere to row,
// then appends the row to the results. It sets the cursor
// Appends the current row to the results. It sets the cursor
// to newCursor and finds the nextNewline. The caller should
// take care to execute user's step function and check for
// preview and end parsing if necessary.
function saveRow(fromCursorToHere, newCursor)
function saveRow(newCursor)
{
row.push(input.substring(cursor, fromCursorToHere));
data.push(row);
row = [];
cursor = newCursor;

4
papaparse.min.js vendored

File diff suppressed because one or more lines are too long

2
parse.jquery.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "parse",
"version": "4.0.1",
"version": "4.0.2",
"title": "Papa Parse",
"description": "Powerful CSV parser that converts CSV to JSON and JSON to CSV. Supports web workers and streaming large files. Fastest CSV parser for JavaScript.",
"keywords": [

16
tests/test-cases.js

@ -176,6 +176,14 @@ var CORE_PARSER_TESTS = [ @@ -176,6 +176,14 @@ var CORE_PARSER_TESTS = [
errors: []
}
},
{
description: "Quoted field at end of row (but not at EOF) has quotes",
input: 'a,b,"c""c"""\nd,e,f',
expected: {
data: [['a', 'b', 'c"c"'], ['d', 'e', 'f']],
errors: []
}
},
{
description: "Empty input string",
input: '',
@ -192,6 +200,14 @@ var CORE_PARSER_TESTS = [ @@ -192,6 +200,14 @@ var CORE_PARSER_TESTS = [
errors: []
}
},
{
description: "Input is just empty fields",
input: ',,\n,,,',
expected: {
data: [['', '', ''], ['', '', '', '']],
errors: []
}
},
{
description: "Input is just a string (a single field)",
input: 'Abc def',

Loading…
Cancel
Save