Results 1 to 3 of 3

Thread: Fetch data from google spread-sheet with each row as a single sentence

  1. #1
    Join Date
    Jan 2014

    Question Fetch data from google spread-sheet with each row as a single sentence

    Hi all,

    I am going through a very critical situation where I cannot find bright ideas to work upon.
    1. I have an google spread sheet which contains few rows and columns.
    2. I want to combine the row together including its column value.(1 row with four columns which results to a single sentence)
    3. Simultaneously each row should form a single sentence from the google spread sheet.

    My spread sheet path: https://docs.google.com/spreadsheets...5P0/edit#gid=0

    I dont know how to strt of with this and which function, code to prefer ?
    Any kind of help is appreaciated.

  2. #2
    Join Date
    Mar 2012
    You need to put the spreadsheet somewhere that is publically accessible. Also, spreadsheet are not a web development issue, so I don't know whether anyone will be able to help. Why did you choose the PHP section? I'm struggling to work out where the thread belongs...

    Anyway, the PHP syntax for concatenating variables is '.', e.g.

    $concat=$col1.' '.$col2.' '.$col3;

    Though I'm not sure whether that is any help to you, as I have no idea how you would interface that to the spreadsheet!!!

  3. #3
    Join Date
    Jan 2014
    Hello all,

    Below is the code which I have tried so far and returns the output which I wanted.

    if ($_FILES["file"]["error"] > 0)
    echo "Error: " . $_FILES["file"]["error"] . "<br>";

    echo "No files...!!!!!";

    echo "<script>alert('No files...!!!!!');window.location.href='upload_file.php';</script>";
    $csv_file = $a;

    if (($getfile = fopen($csv_file, "r")) !== FALSE) {
    $data = fgetcsv($getfile, 1000, ",");
    while (($data = fgetcsv($getfile, 1000, ",")) !== FALSE) {
    //$num = count($data);
    //echo $num;
    //for ($c=0; $c < $num; $c++) {
    $result = $data;
    $str = implode(",", $result);
    $slice = explode(",", $str);

    $col1 = $slice[0];
    $col2 = $slice[1];
    $col3 = $slice[2];
    echo $col1."".$col2."".$col3."<br/>";



    But now the case is that the files are been uploaded from .csv file.
    I want the fetch data from directly "google spread sheet" URL.
    In the baove code what will be the logic to add the spread sheet URl ?
    any help is appreciated.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center