LoginSignup
0
1

More than 3 years have passed since last update.

Embulkメモ

Last updated at Posted at 2020-09-29

embulk github
embulk 公式

はじめに/Embulkとは...

Embulk is a open-source bulk data loader that helps data transfer between various databases, storages, file formats, and cloud services.(公式リファレンスより)
image.png

つまり、元のデータを一気に整形・変換してアウトプットすることができる。
ETLツール。
→抽出(Extract)変換(Transform)書き出し(Load)

Embulk(エンバルク)とは、オープンソースの並列データ転送フレームワークです。「fluentd」のバッチ版のようなバルク処理に特化したプラグインベースのデータローダーです。大規模データセットのバルクインポートを行えます。

<メモ>

bulk: 大きさ、容積、嵩(かさ)、大部分、大半
weblio bulkの意味
バルクインサート(bulk insert): 大量のデータを一気に投入すること
「分かりそう」で「分からない」でも「分かった」気になれるIT用語辞典

環境構築

Mac環境構築
curl --create-dirs -o ~/.embulk/bin/embulk -L "https://dl.embulk.org/embulk-latest.jar"
chmod +x ~/.embulk/bin/embulk
echo 'export PATH="$HOME/.embulk/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
embulk example ./try1
embulk guess   ./try1/seed.yml -o config.yml
embulk preview config.yml
embulk run     config.yml

コマンド一覧

embulk example

  • embulk example PATHで指定したパスに、サンプルCSVと設定ファイルを作成する。

embulk guess

  • -oオプション guess実行後の設定出力先ファイルパス

embulk preview

  • 指定したファイルの実行結果をプレビューする

embulk run

  • 指定したファイルを実行する

config.yml書き方

プラグインに関する設定を書く。
in: インプットプラグインに関する記述
out: アウトプットプラグインに関する記述
filters: フィルタプラグイン関する記述

Embulk(エンバルク)組み込みプラグインの設定覚え書き

プラグイン

Embulk plugin
Embulkはデータ元→データ整形→アウトプットのプラグインが各種用意されている。
gemを使用して各プラグインをインストールが可能。

config.yml.liquid書き方メモ

Embulkはディレクトリ構成に不向きなご様子。

テンプレートエンジンLiquidの機能を使った場合、includeはサブディレクトリには、
対応しているが、「../」のように上の階層を指定するとエラーになることから、階層分けには不向きのようです。
Embulkの設定情報(liquid版) - Qiita

つまり

config
├ sample1_config.yml.liquid
├ sample2_config.yml.liquid
├ sample3_config.yml.liquid
commons
├ _input.yml.liquid
└ _output.yml.liquid

上記の構成にして、*_config.yml.liquidからcommons/以下の共通ファイルを読み込もうとしたのですが、
*_config.yml.liquid内に記述したパスが通らすエラー。

*_config.yml.liquid
{% include '../commons/input' with json_file_path %}

このパスを読み取ってくれないらしい。
そのため、ディレクトリ構成を変更。

sample1_config.yml.liquid
sample2_config.yml.liquid
sample3_config.yml.liquid
commons
├ _input.yml.liquid
└ _output.yml.liquid

*_config.yml.liquid
{% include 'commons/input' with json_file_path %}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1