kopia lustrzana https://github.com/backface/turtlestitch
temporary CSV fix?
rodzic
73d70bec70
commit
e2c44f26e3
22
threads.js
22
threads.js
|
@ -2743,7 +2743,7 @@ Process.prototype.parseCSV = function (string) {
|
|||
// by lines.
|
||||
// taken from:
|
||||
// https://stackoverflow.com/questions/8493195/how-can-i-parse-a-csv-string-with-javascript-which-contains-comma-in-data
|
||||
|
||||
/*
|
||||
var re_valid = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/,
|
||||
re_value = /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^,'"\s\\]*(?:\s+[^,'"\s\\]+)*))\s*(?:,|$)/g,
|
||||
a = [];
|
||||
|
@ -2771,6 +2771,26 @@ Process.prototype.parseCSV = function (string) {
|
|||
a.push('');
|
||||
}
|
||||
return new List(a);
|
||||
*/
|
||||
|
||||
let ret = [''], i = 0, p = '', s = true;
|
||||
for (let l in string) {
|
||||
l = string[l];
|
||||
if ('"' === l) {
|
||||
s = !s;
|
||||
if ('"' === p) {
|
||||
ret[i] += '"';
|
||||
l = '-';
|
||||
} el
|
||||
l = '-';
|
||||
} else if (s && ',' === l)
|
||||
l = ret[++i] = '';
|
||||
else
|
||||
ret[i] += l;
|
||||
p = l;
|
||||
}
|
||||
|
||||
return new List(ret);
|
||||
};
|
||||
|
||||
// Process debugging
|
||||
|
|
Ładowanie…
Reference in New Issue