Chance Callahan
Chance Callahan

Reputation: 23

Use PHP to display a CSV-based Graph

Sorry, I'm a n00b to web languages. I'm trying to upload a CSV file, parse the second and seventh columns, and output it to the Google Graphs API. This is my first ever time trying to do anything with PHP, so, a example would be nice for me to analyze, but, I can try to figure out everything with documentation as well.

Thank you so much for help in any way.

Upvotes: 1

Views: 2484

Answers (3)

Madhukarah
Madhukarah

Reputation: 59

There is a component designed to easily implement the graph by uploading the CSV file: Graph from CSV file

Upvotes: 0

Ryre
Ryre

Reputation: 6181

If you're not married to google graphs, try highcharts. I've used it on several occasions and really like it. They have some tutorials and good sample code to look at, too.

Check the other response for parsing a CSV file; it's spot on.

Upvotes: 0

prehfeldt
prehfeldt

Reputation: 2172

here's how you can upload a file with PHP: http://de3.php.net/move_uploaded_file Parsing a CSV file is easy:

$csv = file('path/to/file.csv');
foreach ($csv as &$current) {
  $current = explode(';', $current);
}

If you then loop through $csv you have the second and seventh column in $csv[$iterator][1] and $csv[$iterator][6].

I haven't used Googles Graph API, so I can't help you with that.

Upvotes: 1

Related Questions