RoysonSilva Posted July 28, 2014 Share Posted July 28, 2014 Hie, I know there are many great logic idea mind out here. I have a code for fetching CSV file data which uploads data and then fetch csv file and then fetch the content from the file and displays in the frontend. Basically, the CSV file created is from the google doc spreadsheet. Its a long process to first download the google spreadsheet in .csv extension and then to upload on my script and fetch the data. But is there any better way to simply fetch data directly from google doc. I tried but did not find a proper solution. <?php //if ($_FILES["https://docs.google.com/spreadsheets/d/1g-SMSAhkqot4BiQwDSw7pALnJAaEycg75eiBK6dz3Hc/edit#gid=0"]["error"] > 0) 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>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br>"; //echo "Stored in: " . $_FILES["file"]["tmp_name"]; $a=$_FILES["file"]["tmp_name"]; $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]; } } } ?> Could someone here please help me out. Please let me know if any concerns. Quote Link to comment Share on other sites More sharing options...
mogosselin Posted July 29, 2014 Share Posted July 29, 2014 Would this help? http://framework.zend.com/manual/1.12/en/zend.gdata.spreadsheets.html https://developers.google.com/google-apps/spreadsheets/ Google seems to offer an API to query your 'Google Drive' and read spreadsheet. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.