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 */ 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), 17 out = [], q; 18 for (var i=0, l=arr.length; i<l; i++) { 19 if (q = arr[i].match(quote)) { 20 for (j=i; j<l; j++) { 21 if (arr[j].charAt(arr[j].length-1) == q[0]) { break; } 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 { out.push(arr[i]); } 28 } 29 30 return out; 31 } 32 33 return function(text) { 34 var lines = text.split(lined); 35 for (var i=0, l=lines.length; i<l; i++) { 36 lines[i] = splitline(lines[i]); 37 } 38 return lines; 39 }; 40 } 41});
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.