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) returns an array of arrays representing the CSV text. 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 var arr = v.split(delim), out = [], q; 16 for (var i=0, l=arr.length; i<l; i++) { 17 if (q = arr[i].match(quote)) { 18 for (j=i; j<l; j++) { 19 if (arr[j].charAt(arr[j].length-1) == q[0]) { 20 break; 21 } 22 } 23 var s = arr.slice(i,j+1).join(delim); 24 out.push(s.substr(1,s.length-2)); 25 i = j; 26 } 27 else { 28 out.push(arr[i]); 29 } 30 } 31 32 return out; 33 } 34 35 return function(text) { 36 var lines = text.split(lined); 37 for (var i=0, l=lines.length; i<l; i++) { 38 lines[i] = splitline(lines[i]); 39 } 40 41 var last = lines.length - 1; 42 if (lines[last].length == 1 && lines[last][0] == "") { 43 lines.splice(last, 1); 44 } 45 46 return lines; 47 }; 48 } 49});
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.