Using CSV file to Populate DataTable

3,308 views
Skip to first unread message

Eddiie

unread,
Apr 11, 2012, 1:47:57 AM4/11/12
to Google Visualization API
I've spent the last 3 hours going in circles trying to understand how
to take a CSV file on my webserver full of data and pass that to
Google Graphs.
Found lots of documentation to have Google make my data into a CSV but
not populate the DataTable for the graphs.

Ultimately what I'd like to do is feed this CSV file in and get a PNG,
GIF, JPG, whatever back. If I can't do that, I'll be happy with a
graph and take it from there.

I am not a programmer. I can barely make a web page. I have followed
examples and can make graphs by building an array manually, but I need
this to work from feeding the Google Graph a CSV file, about 10000
lines.
?

Many thanks!


asgallant

unread,
Apr 11, 2012, 9:05:19 AM4/11/12
to google-visua...@googlegroups.com
Try passing your CSV contents to the CSVToArray function posted here: http://stackoverflow.com/questions/1293147/javascript-code-to-parse-csv-data

You can then pass the output from that to the visualization's arrayToDataTable constructor.  Something like this:

var dataArray = CSVToArray(csv);
var data = new google.visualization.arrayToDataTable(dataArray);
Reply all
Reply to author
Forward
0 new messages