Skip to content

Data Transform

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

16 modules

ModuleDescription
อ่านไฟล์ CSVอ่านและแยกวิเคราะห์ไฟล์ CSV เป็นอาร์เรย์ของออบเจ็กต์
เขียนไฟล์ CSVเขียนอาร์เรย์ของออบเจ็กต์ไปยังไฟล์ CSV
แยกวิเคราะห์ JSONแยกวิเคราะห์สตริง JSON เป็นออบเจ็กต์
JSON Stringifyแปลงออบเจ็กต์เป็นสตริง JSON
JSON เป็น CSVแปลงข้อมูลหรือไฟล์ JSON เป็นรูปแบบ CSV
ข้อมูลพายป์ไลน์เชื่อมโยงการแปลงข้อมูลหลายขั้นตอนในขั้นตอนเดียว
เทมเพลตข้อความเติมเทมเพลตข้อความด้วยตัวแปร
สร้าง XMLสร้างสตริง XML จากอ็อบเจ็กต์หรืออาร์เรย์
แปลง XMLแปลงสตริง XML เป็นอ็อบเจ็กต์
สร้าง YAMLสร้างสตริง YAML จากอ็อบเจ็กต์หรืออาร์เรย์
แปลง YAMLแปลงสตริง YAML เป็นอ็อบเจ็กต์
Keys ของออบเจกต์รับ keys ทั้งหมดจากออบเจกต์
รวมออบเจกต์รวมออบเจกต์หลายตัวเป็นหนึ่งเดียว
ละเว้นออบเจกต์ละเว้น keys ที่กำหนดจากออบเจกต์
เลือกออบเจกต์เลือก keys ที่กำหนดจากออบเจกต์
Values ของออบเจกต์รับ values ทั้งหมดจากออบเจกต์

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 Stringify

data.json.stringify

แปลงออบเจ็กต์เป็นสตริง JSON

Parameters:

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

Output:

FieldTypeDescription
statusstringสถานะการดำเนินการ
jsonstringสถานะการดำเนินการ

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เส้นทางไปยังไฟล์ CSV ที่สร้างขึ้น
column_countnumberเส้นทางไปยังไฟล์ CSV ที่สร้างขึ้น
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-ข้อมูลนำเข้าเพื่อแปลง (array หรือ object)
stepsarrayYes-ข้อมูลนำเข้าเพื่อแปลง (array หรือ object)

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ชื่อแท็กขององค์ประกอบราก
prettybooleanNoTrueจัดรูปแบบ XML ให้อ่านง่าย
encodingstringNoutf-8การเข้ารหัสอักขระสำหรับผลลัพธ์ XML
declarationbooleanNoTrueรวมส่วนหัวประกาศ XML

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
resultobjectXML ที่แปลงเป็นอ็อบเจ็กต์
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
resultanyYAML ที่แปลงเป็นอ็อบเจ็กต์หรืออาร์เรย์
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

Keys ของออบเจกต์

object.keys

รับ keys ทั้งหมดจากออบเจกต์

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary

Output:

FieldTypeDescription
keysarrayรายการ keys ของออบเจกต์
countnumberรายการ keys ของออบเจกต์

Example: Get object keys

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

รวมออบเจกต์

object.merge

รวมออบเจกต์หลายตัวเป็นหนึ่งเดียว

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

ละเว้น keys ที่กำหนดจากออบเจกต์

Parameters:

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

Output:

FieldTypeDescription
resultobjectออบเจกต์ที่ไม่มี keys ที่ละเว้น

Example: Omit sensitive fields

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

เลือกออบเจกต์

object.pick

เลือก keys ที่กำหนดจากออบเจกต์

Parameters:

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

Output:

FieldTypeDescription
resultobjectออบเจกต์ที่มีเฉพาะ keys ที่เลือก

Example: Pick user fields

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

Values ของออบเจกต์

object.values

รับ values ทั้งหมดจากออบเจกต์

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary

Output:

FieldTypeDescription
valuesarrayรายการ values ของออบเจกต์
countnumberรายการ values ของออบเจกต์

Example: Get object values

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

Released under the Apache 2.0 License.