Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery CSV plugin won't split rows into arrays-of-arrays
    primarykey
    data
    text
    <p>I am trying to use the jQuery "CSV" plugin, as documented here: <a href="http://code.google.com/p/js-tables/wiki/CSV" rel="nofollow noreferrer">http://code.google.com/p/js-tables/wiki/CSV</a></p> <p>According to the documentation:</p> <pre><code>// Convert CSV data into array of arrays jQuery.csv()("1,2,3\n4,5,6\n7,8,9\n"); // = [ [1,2,3], [4,5,6], [7,8,9] ] </code></pre> <p>But when I attempt to do something similar, it just seems to treat the "\n" as another character in the middle of an array element.</p> <p>What am I doing wrong? I am using jQuery 1.4.2 and Firefox 3.5.10 for testing. I have also tried it with jQuery 1.3 and get the same result.</p> <p>If it is a problem with the plugin, then can someone suggest another plugin for reading CSV? My ultimate goal is to convert CSV from a string into an HTML table; the only plugin I can find that specifically does this requires the CSV to come from a file, which is not desirable for my task.</p> <p>Here is a minimal test page I put together which illustrates that it's not separating the lines into sub-arrays:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;CSVtest&lt;/title&gt; &lt;script type="text/javascript" src="jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery.csv.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var lines = $.csv()("a,b\nc,d"); alert(lines[0][1]); // Displays: b // c instead of the expected b }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload