embulk-fiter-splitは、指定したカラムの区切り文字でデータを区切り複数行に変換するためのプラグイン @toyama0919さん作成
in:
type: file
path_prefix: sample.txt
parser:
type: jsonl
schema:
- {name: keywords, type: string}
## ここがフィルタの設定
filters:
- type: split
delimiter: ',' # 区切り文字
keep_input: false # 入力カラムを出力するかどうか
target_key: keywords # 入力のカラム名
output_key: keyword # 出力のカラム名
out:
type: stdout
sample.txt
{ "keywords" : "Ruby,Java,Python" }
入力カラムを出力する場合
filters:
- type: split
delimiter: ',' # 区切り文字
keep_input: true # 入力カラムを出力するかどうか
target_key: keywords # 入力のカラム名
output_key: keyword # 出力のカラム名
実行結果
+------------------+----------------+
| keywords:string | keyword:string |
+------------------+----------------+
| Ruby,Java,Python | Ruby |
| Ruby,Java,Python | Java |
| Ruby,Java,Python | Python |
+------------------+----------------+
filters:
- type: split
delimiter: ',' # 区切り文字
keep_input: false # 入力カラムを出力するかどうか
target_key: keywords # 入力のカラム名
output_key: keyword # 出力のカラム名
+----------------+
| keyword:string |
+----------------+
| Ruby |
| Java |
| Python |
+----------------+