1

私の難問は次のとおりです。Googleドキュメントのさまざまなスプレッドシートにたくさんのデータが保存されています。すべてのデータを(分析目的で)単一のスプレッドシートにコンパイルすると、サイズ制限に達します。それが終わったので、私は別の方法が必要でした。

データを取得して、対応する一連の.csvファイルにすべてエクスポートするAppsScriptを作成しました。次に、Googleドキュメントに保存されている30個の.csvファイルからデータを取得し、MySQLサーバーにインポートする必要があります。これは最も効率的な方法ですか?

今のところ、すべての.csvファイルをGoogleドキュメントリストからサーバーにインポートする方法が必要です。サーバーでは、PHPスクリプトでそれらをデータベースにインポートできます。私を正しい方向に向けてもらえますか?

私は研究中に次の投稿を発見しました。これはかなり近いように見えますが、残念ながら、それを私の目的に適合させることに関しては、頭上にあります...

http://gdatatips.blogspot.com/2009/07/download-google-doc-using-php-library.html

function download($client, $url, $format=null) {
  $sessionToken = $client->getHttpClient()->getAuthSubToken();
  $opts = array(
    'http' => array(
      'method' => 'GET',
      'header' => "GData-Version: 3.0\r\n".
                  "Authorization: AuthSub token=\"$sessionToken\"\r\n"
    )
  );
  if ($url != null) {
    $url =  $url . "&exportFormat=$format";
  }
  return file_get_contents($url, false, stream_context_create($opts));
}

// TODO 1: setup a Zend_Gdata_Docs client in $docs_client
// TODO 2: fetch a $feed or $entry
$contentLink = $feed->entries[0]->content->getSrc();
$fileContents = download($docs_client, $contentLink, 'txt');
echo 'Contents of document "' . $feed->entries[0]->title . '":<hr>';
echo "<pre>$fileContents</pre>";

どうもありがとう!どんな援助も大歓迎です!:)

4

2 に答える 2

0

スケジュールされたタスクから開始されるバッチファイルを使用して.csvファイルをダウンロードします(つまり、1日に1回)。次に、バッチファイルでSQL c:\ sql\update_timekeeping.sqlを開始します。update_timekeepingに格納されているSQlコマンド。 SQLテキストファイル。また、計時更新の実行履歴も提供します。

于 2011-07-20T17:45:26.070 に答える
0

file_get_contents()このスクリプトのPHPバージョンに似ているはずだと私には思えます

function file_get_contents(){
  //This function generates a pdf of your current spreadsheet and emails it to yourself as attachment
  //Make sure your spreadsheet is not too big. The pdf size tends to be 200kb/page and if too large
  //if the pdf is too large the urlFetch might timeout

  var AUTH_TOKEN = "xxxxxxxxxxxxxx"; //Enter your AUTH_TOKEN
  //You can receive it from https://appscripts.appspot.com/getAuthToken

  var ssID=SpreadsheetApp.getActiveSpreadsheet().getId()+"&gid="+SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getSheetId();
  var url = "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key="
      + ssID + "&exportFormat=csv"; 
  //Add &gid=x at the end of above url if you only want a particular sheet
  //gid of a sheet can be obtained by the undocumented function getSheetId()
  //ex: SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getSheetId();
  //exportFormat=xls did not work when I tried. I dont know why

  var auth = "AuthSub token=\"" + AUTH_TOKEN + "\"";

  var res = UrlFetchApp.fetch(url, {headers: {Authorization: auth}});
  var content=res.getContentText();
  return content
}
于 2012-05-24T10:43:40.187 に答える