1/* Usage: 2 * jQuery.csv()(csvtext) returns an array of arrays representing the CSV text. 3 * jQuery.csv("\t")(tsvtext) uses Tab as a delimiter (comma is the default) 4 * jQuery.csv("\t", "'")(tsvtext) uses a single quote as the quote character instead of double quotes 5 * jQuery.csv("\t", "'\"")(tsvtext) uses single & double quotes as the quote character 6 * jQuery.csv(",", "", "\n")(tsvtext) ã«ã³ãåºåãã§æ¹è¡ã³ã¼ãã\nã 7 */ 8jQuery.extend({ 9 csv: function(delim, quote, lined) { 10 delim = typeof delim == "string" ? new RegExp( "[" + (delim || "," ) + "]" ) : typeof delim == "undefined" ? "," : delim; 11 quote = typeof quote == "string" ? new RegExp("^[" + (quote || '"' ) + "]" ) : typeof quote == "undefined" ? '"' : quote; 12 lined = typeof lined == "string" ? new RegExp( "[" + (lined || "\r\n") + "]+") : typeof lined == "undefined" ? "\r\n" : lined; 13 14 function splitline (v) { 15 // Split the line using the delimitor 16 var arr = v.split(delim), out = [], q; 17 for (var i=0, l=arr.length; i<l; i++) { 18 if (q = arr[i].match(quote)) { 19 for (j=i; j<l; j++) { 20 if (arr[j].charAt(arr[j].length-1) == q[0]) { 21 break; 22 } 23 } 24 var s = arr.slice(i,j+1).join(delim); 25 out.push(s.substr(1,s.length-2)); 26 i = j; 27 } 28 else { 29 out.push(arr[i]); 30 } 31 } 32 33 return out; 34 } 35 36 return function(text) { 37 var lines = text.split(lined); 38 for (var i=0, l=lines.length; i<l; i++) { 39 lines[i] = splitline(lines[i]); 40 } 41 42 // æå¾ã®è¡ãåé¤ 43 var last = lines.length - 1; 44 if (lines[last].length == 1 && lines[last][0] == "") { 45 lines.splice(last, 1); 46 } 47 48 return lines; 49 }; 50 } 51});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.