Skip to content

Data Transform

CSV, JSON, XML, YAML parsing, generation, and pipeline transformations.

16 modules

ModuleDescription
CSVファイル読み込みCSVファイルを読み込みオブジェクト配列に変換する
CSVファイル書き込みオブジェクト配列をCSVファイルに書き込む
JSONパースJSON文字列をオブジェクトに変換する
JSON文字列化オブジェクトをJSON文字列に変換する
JSONからCSV変換JSONデータまたはファイルをCSV形式に変換する
データパイプライン複数のデータ変換を一度にチェーンする
テキストテンプレート変数を使用してテキストテンプレートを埋める
XML生成オブジェクトや配列からXML文字列を生成
XML解析XML文字列をオブジェクトに解析
YAML生成オブジェクトや配列からYAML文字列を生成
YAML解析YAML文字列をオブジェクトに解析
オブジェクトキーオブジェクトからすべてのキーを取得
オブジェクトマージ複数のオブジェクトを1つにマージ
オブジェクト除外オブジェクトから特定のキーを除外
オブジェクト選択オブジェクトから特定のキーを選択
オブジェクト値オブジェクトからすべての値を取得

Modules

CSVファイル読み込み

data.csv.read

CSVファイルを読み込みオブジェクト配列に変換する

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes-Path to the file
delimiterselect (,, ;, , `, `)No,
encodingselect (utf-8, ascii, latin-1, utf-16, gbk, big5)Noutf-8Character encoding for the file
skip_headerbooleanNoFalseSkip first row (header)

Output:

FieldTypeDescription
statusstring操作ステータス
dataarray行オブジェクトの配列
rowsnumber行数
columnsarrayカラム名の配列

Example: Example

yaml
file_path: data/users.csv
delimiter: ,
encoding: utf-8

CSVファイル書き込み

data.csv.write

オブジェクト配列をCSVファイルに書き込む

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes-Path to the file
dataarrayYes-Array of data items to process
delimiterselect (,, ;, , `, `)No,
encodingselect (utf-8, ascii, latin-1, utf-16, gbk, big5)Noutf-8Character encoding for the file

Output:

FieldTypeDescription
statusstring操作ステータス
file_pathstringファイルパス
rows_writtennumber書き込まれた行数

Example: Example

yaml
file_path: output/results.csv
data: [{"name": "John", "score": 95}, {"name": "Jane", "score": 87}]

JSONパース

data.json.parse

JSON文字列をオブジェクトに変換する

Parameters:

NameTypeRequiredDefaultDescription
json_stringstringYes-JSON string to parse into an object or array

Output:

FieldTypeDescription
statusstring操作ステータス
dataobjectパースされたデータ

Example: Example

yaml
json_string: {"name": "John", "age": 30}

JSON文字列化

data.json.stringify

オブジェクトをJSON文字列に変換する

Parameters:

NameTypeRequiredDefaultDescription
dataobjectYes-Data object to process
prettybooleanNoFalseFormat with indentation
indentnumberNo2Indentation spaces (if pretty=true)

Output:

FieldTypeDescription
statusstring操作ステータス
jsonstringJSON文字列

Example: Example

yaml
data: {"name": "John", "age": 30}
pretty: true

JSONからCSV変換

data.json_to_csv

JSONデータまたはファイルをCSV形式に変換する

Parameters:

NameTypeRequiredDefaultDescription
input_dataanyYes-JSON data (array of objects) or path to JSON file
output_pathstringNo/tmp/output.csvPath where the output file will be saved
delimiterselect (,, ;, , `, `)No,
include_headerbooleanNoTrueInclude column headers in first row
flatten_nestedbooleanNoTrueFlatten nested objects using dot notation (e.g., address.city)
columnsarrayNo[]Specific columns to include (empty = all columns)

Output:

FieldTypeDescription
output_pathstring生成されたCSVファイルのパス
row_countnumber書き込まれた行数
column_countnumberカラム数
columnsarrayカラム名の配列

Example: Convert JSON array to CSV

yaml
input_data: [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]
output_path: /tmp/users.csv

Example: Convert JSON file

yaml
input_data: /path/to/data.json
output_path: /path/to/output.csv

データパイプライン

data.pipeline

複数のデータ変換を一度にチェーンする

Parameters:

NameTypeRequiredDefaultDescription
inputanyYes-変換する入力データ(配列またはオブジェクト)
stepsarrayYes-変換する入力データ(配列またはオブジェクト)

Output:

FieldTypeDescription
resultany適用する変換ステップの配列
original_countinteger変換されたデータ
result_countinteger変換されたデータ
steps_appliedinteger変換後のアイテム数

Example: Example

yaml
input: ${input.users}
steps: [{"filter": {"field": "active", "condition": "eq", "value": true}}, {"sort": {"field": "name", "order": "asc"}}]

Example: Example

yaml
input: ${input.records}
steps: [{"map": {"extract": "id"}}, {"limit": 10}]

Example: Example

yaml
input: ${input.data}
steps: [{"filter": {"field": "status", "condition": "eq", "value": "completed"}}, {"pick": ["id", "name", "timestamp"]}, {"sort": {"field": "timestamp", "order": "desc"}}, {"skip": 5}, {"limit": 20}]

テキストテンプレート

data.text.template

変数を使用してテキストテンプレートを埋める

Parameters:

NameTypeRequiredDefaultDescription
templatestringYes-Text template with {variable} placeholders
variablesobjectYes-Object with variable values

Output:

FieldTypeDescription
statusstring操作ステータス
resultstringテンプレート結果

Example: Example

yaml
template: Hello {name}, you scored {score} points!
variables: {"name": "Alice", "score": 95}

XML生成

data.xml.generate

オブジェクトや配列からXML文字列を生成

Parameters:

NameTypeRequiredDefaultDescription
dataobjectYes-XMLに変換するデータ
root_tagstringNorootルート要素のタグ名
prettybooleanNoTrueXML出力を整形して表示
encodingstringNoutf-8XML出力の文字エンコーディング
declarationbooleanNoTrueXML宣言ヘッダーを含める

Output:

FieldTypeDescription
xmlstring生成されたXML文字列

Example: Example

yaml
data: {"user": {"@attributes": {"id": "1"}, "name": "John", "age": "30"}}
root_tag: users
pretty: true

XML解析

data.xml.parse

XML文字列をオブジェクトに解析

Parameters:

NameTypeRequiredDefaultDescription
contentstringNo-解析するXML文字列
file_pathstringNo-解析するXMLファイルのパス
preserve_attributesbooleanNoTrue解析された出力でXML属性を保持

Output:

FieldTypeDescription
resultobjectオブジェクトとして解析されたXML
root_tagstringルート要素のタグ名

Example: Example

yaml
content: <users><user id="1"><name>John</name></user></users>
preserve_attributes: true

YAML生成

data.yaml.generate

オブジェクトや配列からYAML文字列を生成

Parameters:

NameTypeRequiredDefaultDescription
dataanyYes-YAMLに変換するデータ
default_flow_stylebooleanNoFalseネストされた構造にフロースタイルを使用
sort_keysbooleanNoFalseキーをアルファベット順にソート
indentnumberNo2インデントのスペース数
allow_unicodebooleanNoTrue出力にユニコード文字を許可

Output:

FieldTypeDescription
yamlstring生成されたYAML文字列

Example: Example

yaml
data: {"name": "John", "age": 30, "cities": ["NYC", "LA"]}
sort_keys: false
indent: 2

YAML解析

data.yaml.parse

YAML文字列をオブジェクトに解析

Parameters:

NameTypeRequiredDefaultDescription
contentstringNo-解析するYAML文字列
file_pathstringNo-解析するYAMLファイルのパス
multi_documentbooleanNoFalseマルチドキュメントYAMLを解析(---で区切る)

Output:

FieldTypeDescription
resultanyオブジェクトまたは配列として解析されたYAML
typestring解析された結果のタイプ

Example: Example

yaml
content: name: John
age: 30
cities:
  - NYC
  - LA
multi_document: false

Example: Example

yaml
content: ---
name: John
---
name: Jane
multi_document: true

オブジェクトキー

object.keys

オブジェクトからすべてのキーを取得

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary

Output:

FieldTypeDescription
keysarrayオブジェクトキーのリスト
countnumberオブジェクトキーのリスト

Example: Get object keys

yaml
object: {"name": "John", "age": 30, "city": "NYC"}

オブジェクトマージ

object.merge

複数のオブジェクトを1つにマージ

Parameters:

NameTypeRequiredDefaultDescription
objectsarrayYes-Array of objects to process

Output:

FieldTypeDescription
resultobjectマージされたオブジェクト

Example: Merge user data

yaml
objects: [{"name": "John", "age": 30}, {"city": "NYC", "country": "USA"}, {"job": "Engineer"}]

オブジェクト除外

object.omit

オブジェクトから特定のキーを除外

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary
keysarrayYes-Keys to pick or omit

Output:

FieldTypeDescription
resultobject除外されたキーを含まないオブジェクト

Example: Omit sensitive fields

yaml
object: {"name": "John", "age": 30, "password": "secret", "ssn": "123-45-6789"}
keys: ["password", "ssn"]

オブジェクト選択

object.pick

オブジェクトから特定のキーを選択

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary
keysarrayYes-Keys to pick or omit

Output:

FieldTypeDescription
resultobject選択されたキーのみを含むオブジェクト

Example: Pick user fields

yaml
object: {"name": "John", "age": 30, "email": "john@example.com", "password": "secret"}
keys: ["name", "email"]

オブジェクト値

object.values

オブジェクトからすべての値を取得

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary

Output:

FieldTypeDescription
valuesarrayオブジェクト値のリスト
countnumberオブジェクト値のリスト

Example: Get object values

yaml
object: {"name": "John", "age": 30, "city": "NYC"}

Released under the Apache 2.0 License.