{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Embulk Bulk Import From Tsv Files","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"embulk-bulk-import-from-tsv-files","__idx":0},"children":["Embulk Bulk Import From Tsv Files"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["オープンソースの一括データローダーである ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Embulk"]}," を使用して、TSVファイルからTreasure Dataにデータをインポートできます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191021-194448.33463c75cf3cb8b1a37595872537be60b30cee4f234d918acbc8fa2cb005f933.d2564ff8.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件","__idx":1},"children":["前提条件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Dataの基本的な知識。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://www.embulk.org/docs/"},"children":["Embulk"]},"の基本的な知識。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.jruby.org/download"},"children":["JRuby"]},"がインストールおよび設定されている必要があります。Embulk v0.10.50およびv0.11.0にはJRubyが含まれていないため、手動でインストールおよび設定する必要があります。(EmbulkとJRubyの設定の詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.embulk.org/articles/2023/04/13/embulk-v0.11-is-coming-soon.html"},"children":["Embulk v0.11 is coming soon"]},"の「JRuby」セクションを参照してください。)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"embulkとは","__idx":2},"children":["Embulkとは"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Embulkを使用すると、さまざまなデータベース、ストレージの場所、ファイル形式、クラウドサービス間でデータを転送できます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"embulkのインストール方法","__idx":3},"children":["Embulkのインストール方法"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"linuxmacおよびbsd","__idx":4},"children":["Linux、MacおよびBSD"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["EmbulkはJavaアプリケーションです。Javaがインストールされていることを確認してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次の4つのコマンドで、Embulkをホームディレクトリにインストールします:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl --create-dirs -o ~/.embulk/bin/embulk -L \"http://dl.embulk.org/embulk-latest.jar\"\nchmod +x ~/.embulk/bin/embulk\necho 'export PATH=\"$HOME/.embulk/bin:$PATH\"' >> ~/.bashrc\nsource ~/.bashrc\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"windows","__idx":5},"children":["Windows"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["EmbulkはJavaアプリケーションです。Javaがインストールされていることを確認してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["cmd.exeまたはPowerShell.exeで次のコマンドを使用して、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["embulk.bat"]},"をダウンロードできます:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"PowerShell -Command \\\n  \"& {Invoke-WebRequest http://dl.embulk.org/embulk-latest.jar -OutFile embulk.bat}\"\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"treasure-data-pluginのインストール方法","__idx":6},"children":["Treasure Data Pluginのインストール方法"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["pluginを使用して、さまざまなシステムやファイル形式からデータをロードできます。公開されているpluginのリストを表示するには、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://plugins.embulk.org/"},"children":["カテゴリ別のpluginリスト"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次のコマンドでembulk-output-td pluginをインストールします。このpluginは、レコードをTreasure Dataにインポートします。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"embulk gem install embulk-output-td\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"seed設定ファイルの作成","__idx":7},"children":["Seed設定ファイルの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["お好みのテキストエディタを使用して、入力(file)および出力(TD)パラメータを定義するembulk設定ファイル(例:seed.yml)を作成します。例:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n    type: file\n    path_prefix: /path/to/files/sample_    # path of *.csv or *.tsv file on your local machine\nout:\n    type: td\n    apikey: xxxxxxxxxxxx\n    endpoint: api.treasuredata.com\n    database: dbname\n    table: tblname\n    time_column: time\n    mode: replace\n    #by default mode: append is used, if not defined. Imported records are appended to the target table with this mode.\n    #mode: replace, replaces existing target table\n    default_timestamp_format: '%Y-%m-%d %H:%M:%S'\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["これはサンプルデータです。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"id,account,time,purchase,comment\n1,32864,2015-01-27 19:23:49,20150127,embulk\n2,14824,2015-01-27 19:01:23,20150127,embulk jruby\n3,27559,2015-01-28 02:20:02,20150128,\"Embulk \"\"TSV\"\" parser plugin\"\n4,11270,2015-01-29 11:54:36,20150129,NULL\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["embulk-local-file-inputで使用可能な追加パラメータの詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.embulk.org/docs/built-in.html#local-file-input-plugin"},"children":["Embulk Local file input"]},"を参照してください。また、embulk-output-tdの詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/embulk-output-td#td-output-plugin-for-embulk"},"children":["TD output plugin for Embulk"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"フィールドの推測loadymlの生成","__idx":8},"children":["フィールドの推測(load.ymlの生成)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Embulkのguessオプションは、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["seed.yml"]},"を使用してターゲットファイルを読み取り、カラムタイプと設定を自動的に推測し、この情報を含む新しいファイル",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["load.yml"]},"を作成します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"embulk guess seed.yml -o load.yml\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: file\n  path_prefix: /path/to/files/sample_\n  'last_path:': /path/to/files/sample_02.tsv\n  parser:\n    charset: UTF-8\n    newline: CRLF\n    type: tsv\n    delimiter: ','\n    quote: '\"'\n    escape: '\"'\n    null_string: 'NULL'\n    trim_if_not_quoted: false\n    skip_header_lines: 1\n    allow_extra_columns: false\n    allow_optional_columns: false\n    columns:\n      - name: id\n        type: long\n      - name: account\n        type: long\n      - name: time\n        type: timestamp\n        format: '%Y-%m-%d %H:%M:%S'\n      - name: purchase\n        type: timestamp\n        format: '%Y%m%d'\n      - name: comment\n        type: string\n  out:\n    type: td\n    apikey: xxxxx\n    endpoint: api.treasuredata.com\n    database: dbname\n    table: tblname\n    time_column: time\n    mode: replace\n    default_timestamp_format: '%Y-%m-%d %H:%M:%S'\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"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":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ロードジョブを実行する前に、TD でデータベースとテーブルを作成する必要があります。代替方法：1) データベースを追加する必要がある場合、または 2) .yml ファイルに auto_create_table パラメータを追加せずにテーブルを追加する必要がある場合は、以下の TD コマンドを実行してください。"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"td database:create dbname\ntd table:create dbname tblname\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://console.treasuredata.com/app/databases"},"children":["Treasure コンソール"]}," を使用してデータベースとテーブルを作成することもできます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["embulk preview load.yml"]}," コマンドを使用してデータをプレビューできます。カラムの型やデータに問題がある場合は、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["load.yml"]}," ファイルを直接編集して再度プレビューして確認できます。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["guess"]}," オプションで満足のいく結果が得られない場合は、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://www.embulk.org/docs/built-in.html#csv-parser-plugin"},"children":["CSV/TSV parser plugin options"]}," を使用して、要件に応じて ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["load.yml"]}," のパラメータを手動で変更できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"embulk preview load.yml\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ロードジョブの実行","__idx":9},"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":["データのサイズによっては、ジョブの完了に数分から数時間かかる場合があります。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"付録","__idx":10},"children":["付録"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Bulk Import プログラム（td-import）を使用して TSV ファイルからデータをインポートすることもできます。ただし、td-import は積極的にメンテナンスされておらず、将来的に非推奨となる可能性があることに注意してください。そのため、Embulk の使用を強く推奨します。"]}]},"headings":[{"value":"Embulk Bulk Import From Tsv Files","id":"embulk-bulk-import-from-tsv-files","depth":1},{"value":"前提条件","id":"前提条件","depth":2},{"value":"Embulkとは","id":"embulkとは","depth":2},{"value":"Embulkのインストール方法","id":"embulkのインストール方法","depth":2},{"value":"Linux、MacおよびBSD","id":"linuxmacおよびbsd","depth":3},{"value":"Windows","id":"windows","depth":3},{"value":"Treasure Data Pluginのインストール方法","id":"treasure-data-pluginのインストール方法","depth":2},{"value":"Seed設定ファイルの作成","id":"seed設定ファイルの作成","depth":1},{"value":"フィールドの推測(load.ymlの生成)","id":"フィールドの推測loadymlの生成","depth":2},{"value":"ロードジョブの実行","id":"ロードジョブの実行","depth":2},{"value":"付録","id":"付録","depth":2}],"frontmatter":{"seo":{"title":"Embulk Bulk Import From Tsv Files"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/embulk-bulk-import-from-tsv-files","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}