{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Embulk Bulk Import From Google Sheets","description":"Google SheetsからTreasure AIへのデータインポートを、Embulkプラグインを使用して行う方法を解説する技術ドキュメントページです。","siteUrl":"https://docs.treasure.ai","lang":"en-US","jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.treasure.ai/","name":"Treasure AI","url":"https://www.treasure.ai/","logo":"https://www.treasure.ai/hubfs/assets/images/logos/primary-logo.svg"},{"@type":"WebSite","@id":"https://docs.treasure.ai/#website","name":"Treasure AI Documentation","url":"https://docs.treasure.ai/","inLanguage":["en","ja"],"publisher":{"@id":"https://www.treasure.ai/"}}]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"embulk-bulk-import-from-google-sheets","__idx":0},"children":["Embulk Bulk Import From Google Sheets"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この記事では、embulk-input-google_spreadsheets入力プラグインを使用して、Google SheetsからTreasure Dataにデータをインポートする方法について説明します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のトピックに進みます:"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"danger"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このコンテンツは古いため、今後更新されません。Treasure Dataでは、ネイティブの",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/int/google-sheets-import-integration"},"children":["Google Sheetsインテグレーション"]},"の使用を推奨しています。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件","__idx":1},"children":["前提条件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataの基礎知識"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://www.embulk.org/docs/"},"children":["Embulk"]},"の基礎知識"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["EmbulkはJavaアプリケーションです。Javaがインストールされていることを確認してください。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/integration-hub/batch/import/bulk-data-import#installing-bulk-data-import"},"children":["Installing Bulk Data Import"]},"の手順に従ってください。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://www.embulk.org/docs/"},"children":["Embulkおよびembulk-output-tdプラグイン"]},"がマシンにインストールされていること。"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"embulk-input-google_spreadsheetsプラグインのインストール","__idx":2},"children":["embulk-input-google_spreadsheetsプラグインのインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["embulk-input-google_spreadsheetsプラグインをインストールするには、次のコマンドを実行します:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"embulk gem install embulk-input-google_spreadsheets\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"必要なgoogle-api認証情報の取得","__idx":3},"children":["必要なGoogle API認証情報の取得"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["EmbulkがGoogle Sheets APIに接続するには、さまざまな認証オプションが利用可能です。この例では、JSONキーファイルを必要とする",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["authorized_user"]},"メソッドを使用します。キーファイルはGoogle APIコンソールから取得できます。このキーファイルには、Google Sheets APIへの接続を許可する認証情報が含まれています。Embulkプラグインの実行に必要な3つのフィールドがあります。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"* client_id\n* client_secret\n* refresh_token\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["既存のGoogle APIプロジェクトからキーファイルをダウンロードする必要があります。プロジェクトを作成していない場合は、Googleが提供するこのウィザードを使用してプロジェクトを作成し、Google Sheets APIを有効にすることができます。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://console.developers.google.com/flows/enableapi?apiid=sheets.googleapis.com"},"children":["Google Sheets APIウィザード"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Credentials > Create Credentials > OAuth ClientID > Web Applicationに移動します。名前を入力して「Create」をクリックします。次の画面にクライアントIDとクライアントシークレットが表示されます。JSONキーファイルに必要なため、これらをコピーしてください。これらの手順を完了すると、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["client_id"]},"と",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["client_secret"]},"が提供されます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"google-oauth-20-playgroundリダイレクトuriの追加","__idx":4},"children":["Google OAuth 2.0 PlaygroundリダイレクトURIの追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Google OAuth 2.0 Playgroundからリフレッシュトークンを取得する必要があります。作成した認証情報の承認済みリダイレクトURIに、OAuth 2.0 PlaygroundリダイレクトURI(",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.google.com/oauthplayground"},"children":["https://developers.google.com/oauthplayground"]},")を追加する必要があります。"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Google OAuth 2.0 Playgroundで使用する認証情報を編集するには、鉛筆アイコンを選択します。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191021-195257.838c1f343dcbda0b041055d8fb826b79bda29a1aaf9532a3803b12b198e1f27c.0563afda.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Authorized Redirect URIフィールドに、Auth PlaygroundのURL: ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.google.com/oauthplayground"},"children":["https://developers.google.com/oauthplayground"]},"を入力します。Enterキーを押して、「保存」を選択します。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191021-195308.303d1022fa20fcb5e9430c1d0f3effb5e779b3da62e3adc880d16509e0675e81.0563afda.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["必要な残りの認証情報はリフレッシュトークンです。リフレッシュトークンを取得する1つの方法は、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.google.com/oauthplayground/"},"children":["Google OAuth 2.0 Playground"]},"で利用可能なGoogle OAuth 2.0 Playgroundを使用することです。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["右上の歯車アイコンを選択し、「Use your own OAuth credentials」を選択してください。OAuth Client IDとOAuth Client secretフィールドに、Google APIコンソールから取得した認証情報を挿入します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["左側のAPIリストから、Google Sheets API v4を選択します。次に、Step 2. - Exchange authorization code for tokensに進みます。「Exchange authorization code for tokens」ボタンを押すと、Refresh TokenとAccess Tokenフィールドが入力されます。リフレッシュトークンフィールドの値は、Embulkが必要とするJSONキーファイルに記録する必要がある値です。JSONキーファイルのすべてのコンポーネントが収集されたら、Embulkの設定を開始する準備が整いました。JSONキーファイルの形式は次のとおりです:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"client_id\": \"xxxxxxxxxx\",\n    \"client_secret\": \"xxxxxxxxxx\",\n    \"refresh_token\": \"xxxxxxxxxx\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"embulk設定ファイルの作成","__idx":5},"children":["Embulk設定ファイルの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["お気に入りのテキストエディターを使用して、入力(Google Sheets)と出力(TD)のパラメーターを定義するEmbulk設定ファイルを作成します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の例では、必要なJSONキーファイルがインラインで使用されています。追加のパラメーターの詳細や他の例については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/medjed/embulk-input-google_spreadsheets"},"children":["Embulk Input Google Sheets"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["プラグインの実行に必要なフィールドは、spreadsheets_urlとworksheet_titleです。インポートしようとしているシートの関連する詳細を編集してください。出力セクションにも同様に適用され、Treasure Dataに出力されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この例では、設定ファイルで使用されている詳細に一致する関連テーブルをTreasure Dataですでに作成していることを前提としています。例えば、databaseはデータ用に作成されたデータベース、tableはそのデータベース内でデータを受信するテーブルです。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n    type: google_spreadsheets\n    auth_method: authorized_user\n    json_keyfile:\n        content: |\n            {\n                \"client_id\": \"xxxxxxxxxx\",\n                \"client_secret\": \"xxxxxxxxxx\",\n                \"refresh_token\": \"xxxxxxxxxx\"\n            }\n    spreadsheets_url: https://docs.google.com/spreadsheets/d/1xP_ZBA-Or4sJ63Zj99-JreuAFGn7Y2gcUKd1vtwSqwM/edit#gid=0\n    worksheet_title: title\n    start_row: starting row\n    default_timezone: timezone to be used\n    null_string: '\\N'\n    default_typecast: strict\n    columns:\n        - {name: color, type: string}\n        - {name: size, type: string}\n        - {name: type, type: string}\nout:\n    type: td\n    apikey: xxxxxxxxxxxx\n    endpoint: api.treasuredata.com\n    database: dbname\n    table: tblname\n    time_column: datecolumn\n    mode: replace\n    #デフォルトでは、定義されていない場合、mode: appendが使用されます。このモードでは、インポートされたレコードがターゲットテーブルに追加されます。\n    #mode: replaceは、既存のターゲットテーブルを置き換えます\n    default_timestamp_format: '%d/%m/%Y'\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["load.ymlに「auto_create_table: true」パラメーターを追加して、存在しないテーブルが自動的に作成されるようにします。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["これは、.ymlファイルのauto_create_tableパラメーターの例です。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"out:\n  type: td\n  apikey: your apikey\n  endpoint: api.treasuredata.com\n  database: dbname\n  table: tblname\n  time_column: created_at\n  auto_create_table: true\n  mode: append\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ロードジョブを実行する前に、TDでデータベースとテーブルを作成する必要があります。または、1) データベースを追加する必要がある場合、または2) .ymlファイルにauto_create_tableパラメーターを追加せずにテーブルを追加する必要がある場合は、次のTDコマンドを実行します:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td database:create dbname\n$ td table:create dbname tblname\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://console.treasuredata.com/app/databases"},"children":["Treasure コンソール"]},"を使用してデータベースとテーブルを作成することもできます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ロードジョブの実行","__idx":6},"children":["ロードジョブの実行"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次のコマンドを実行して、インポートジョブを発行します:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"embulk run load.yml\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["インポートジョブの実行時間は、インポートするデータのサイズによって異なります。ジョブが完了すると、Embulk設定ファイルで使用されたTDデータベースとテーブルにデータが反映されます。"]}]},"headings":[{"value":"Embulk Bulk Import From Google Sheets","id":"embulk-bulk-import-from-google-sheets","depth":1},{"value":"前提条件","id":"前提条件","depth":2},{"value":"embulk-input-google_spreadsheetsプラグインのインストール","id":"embulk-input-google_spreadsheetsプラグインのインストール","depth":2},{"value":"必要なGoogle API認証情報の取得","id":"必要なgoogle-api認証情報の取得","depth":2},{"value":"Google OAuth 2.0 PlaygroundリダイレクトURIの追加","id":"google-oauth-20-playgroundリダイレクトuriの追加","depth":2},{"value":"Embulk設定ファイルの作成","id":"embulk設定ファイルの作成","depth":2},{"value":"ロードジョブの実行","id":"ロードジョブの実行","depth":2}],"frontmatter":{"seo":{"title":"Embulk Bulk Import From Google Sheets","description":"Google SheetsからTreasure AIへのデータインポートを、Embulkプラグインを使用して行う方法を解説する技術ドキュメントページです。"}},"lastModified":"2026-06-17T07:22:53.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/embulk-bulk-import-from-google-sheets","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}