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 @@
{ {
"name": "Papa-Parse", "name": "Papa-Parse",
"version": "4.0.1", "version": "4.0.2",
"main": "papaparse.js", "main": "papaparse.js",
"homepage": "http://papaparse.com", "homepage": "http://papaparse.com",
"authors": [ "authors": [

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "papaparse", "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.", "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": [ "keywords": [
"csv", "csv",

14
papaparse.js

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

16
tests/test-cases.js

@ -176,6 +176,14 @@ var CORE_PARSER_TESTS = [
errors: [] 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", description: "Empty input string",
input: '', input: '',
@ -192,6 +200,14 @@ var CORE_PARSER_TESTS = [
errors: [] errors: []
} }
}, },
{
description: "Input is just empty fields",
input: ',,\n,,,',
expected: {
data: [['', '', ''], ['', '', '', '']],
errors: []
}
},
{ {
description: "Input is just a string (a single field)", description: "Input is just a string (a single field)",
input: 'Abc def', input: 'Abc def',

Loading…
Cancel
Save