View Full Version : CSV to array

Rory Barrett
10-01-2012, 04:56 AM
Hello fellow Javascript users

I am keen to have a simple script that reads a csv file in the samefolder as my html page and puts it in a javascript array. I succeeded in getting a script to display the casv file as a table on the html page however it would be extremely useful to get the csv data into an array. I have been using jquery but I must be making some major errors.

Rory Barrett

10-01-2012, 05:04 AM
in broad terms, you would make an ajax call, get the content of the csv file, and use the javascript split() method to split that content on the commas, which results in a useable array.

It's about 99% likely that your existing code only needs a minor tweak to get that happening. In fact, I'm curious as to how you get the CSVs into a table without doing the above or something similar. Can you post your working code?