<p><strong><a href="http://github.com/evanplaice/jquery-csv/" rel="nofollow noreferrer">jQuery-CSV</a></strong></p>
<p>它是一个jQuery插件,设计用于将CSV解析为JavaScript数据的端到端解决方案。它处理<a href="https://www.rfc-editor.org/rfc/rfc4180" rel="nofollow noreferrer">RFC 4180</a>中显示的每一个边缘情况,以及规范缺失的Excel/Google电子表格导出弹出的一些情况(即,主要涉及空值)</p>
<p><em>示例:</em></p>
<blockquote>
<p>track,artist,album,year</p>
<p>Dangerous,'Busta Rhymes','When Disaster Strikes',1997</p>
</blockquote>
<pre><code>// Calling this
music = $.csv.toArrays(csv)
// Outputs...
[
["track", "artist", "album", "year"],
["Dangerous", "Busta Rhymes", "When Disaster Strikes", "1997"]
]
console.log(music[1][2]) // Outputs: 'When Disaster Strikes'
</code></pre>
<p><strong>更新:</strong></p>
<p>哦,是的,我也应该提到它是完全可配置的</p>
<pre><code>music = $.csv.toArrays(csv, {
delimiter: "'", // Sets a custom value delimiter character
separator: ';', // Sets a custom field separator character
});
</code></pre>
<p><strong>更新2:</strong></p>
<p>它现在也可以与Node.js上的jQuery一起使用。因此,您可以选择使用相同的库进行客户端或服务器端解析</p>
<p><strong>更新3:</strong></p>
<p>自从谷歌代码关闭以来,<a href="http://github.com/evanplaice/jquery-csv" rel="nofollow noreferrer">jquery-csv has been migrated to GitHub</a></p>
<p>免责声明:我也是jQuery CSV的作者</em></p>