开发者

Convert CSV to multi dimensional array in Javascript

I'm reading data from a CSV file using jQuery's Ajax function. I have been using a Jquery plugin called Jquery CSV to convert the data into an array, but in Internet Explorer the array is returning different keys for some reason.

The code for the ajax call and the plugin processing the data was:

var ourOffices = new Array();
$.get(pathToData, function(data) {
   ourOffices = jQuery.csv("|")(data);
});

Can someone point me in the right direction to coding this conversion without a plug in.

The fields are separated by '|' . Each record is on a new line, of which there are 300. Also of note, which might be why the first plugin misbehaves, is that some of the data in the CSV contain special characters, li开发者_如何学编程ke accents.

Thanks.

p.s. I would supply some example data, but its not appropriate to do so, sorry.


I'm sure you have seen the comment in the plugin split() doesn't work properly on IE. "a,,b".split(",") returns ["a", "b"] and not ["a", "", "b"] could that be your issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜