0

Hi, story goes...

I need to process a timesheet - I want to use a csv file of the spreadsheet, so I was hoping to plug in the path to what Google said was a CSV output of a spreadsheet... https://spreadsheets0.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AhhCntOrEg9FdF9PZkIwY08tZTdwd3lkYkJFNEtkMkE&single=true&gid=1&output=csv

Unfortunately if you click on that link, it prompts you to download the file, instead of just printing out the plain text file (which I was hoping for)... I know there is a whole API for spreadsheets but its a headache and I want something easy-peasy...

How can I get a realtime dynamic csv file of my spreadsheet?

Thanks

3
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by almostbob
0

you can try curl:

$URL = 'https://spreadsheets0.google.com/spr...d=1&output=csv';
$ch = curl_init(); // initialize the cURL session
curl_setopt($ch, CURLOPT_URL, $URL);  // tell it which URL to go to (minus the parameters)
curl_setopt($ch, CURLOPT_GET, 1);  // tell it that you want to send an HTTP GET request

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret_value = curl_exec ($ch); // do it
curl_close ($ch); // close the session   
    // $ret_value should be your csv response
    echo $ret_value;
    $pieces = explode(",",$ret_value);
    foreach($pieces as $piece) {

Edited by pyTony: fixed formatting

0

oh, there is no curlopt_get ( I had modified some of my code that I use for a post)
so:
CURLOPT_HTTPGET

and you don't have to set that in the first place unless it is returning other because a default curl request is 'GET' in the first place.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.