Skip to content

Data Transform

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

16 modules

ModuleDescription
Ler Arquivo CSVLer e analisar arquivo CSV em array de objetos
Escrever Arquivo CSVEscrever array de objetos em arquivo CSV
Analisar JSONAnalisar string JSON em objeto
Stringify JSONConverter objeto para string JSON
JSON para CSVConverter dados ou arquivos JSON para formato CSV
Pipeline de DadosEncadeie várias transformações de dados em uma única etapa
Template de TextoPreencher template de texto com variaveis
Gerar XMLGerar string XML a partir de objeto ou array
Analisar XMLAnalisar string XML em objeto
Gerar YAMLGerar string YAML a partir de objeto ou array
Analisar YAMLAnalisar string YAML em objeto
Chaves do ObjetoObter todas as chaves de um objeto
Mesclar ObjetosMesclar multiplos objetos em um
Omitir do ObjetoOmitir chaves especificas de um objeto
Selecionar do ObjetoSelecionar chaves especificas de um objeto
Valores do ObjetoObter todos os valores de um objeto

Modules

Ler Arquivo CSV

data.csv.read

Ler e analisar arquivo CSV em array de objetos

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
statusstringStatus da operacao
dataarrayStatus da operacao
rowsnumberStatus da operacao
columnsarrayArray de objetos de linha

Example: Example

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

Escrever Arquivo CSV

data.csv.write

Escrever array de objetos em arquivo 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
statusstringStatus da operacao
file_pathstringStatus da operacao
rows_writtennumberStatus da operacao

Example: Example

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

Analisar JSON

data.json.parse

Analisar string JSON em objeto

Parameters:

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

Output:

FieldTypeDescription
statusstringStatus da operacao
dataobjectStatus da operacao

Example: Example

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

Stringify JSON

data.json.stringify

Converter objeto para string JSON

Parameters:

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

Output:

FieldTypeDescription
statusstringStatus da operacao
jsonstringStatus da operacao

Example: Example

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

JSON para CSV

data.json_to_csv

Converter dados ou arquivos JSON para formato 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_pathstringCaminho para o arquivo CSV gerado
row_countnumberCaminho para o arquivo CSV gerado
column_countnumberCaminho para o arquivo CSV gerado
columnsarrayNumero de linhas escritas

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

Pipeline de Dados

data.pipeline

Encadeie várias transformações de dados em uma única etapa

Parameters:

NameTypeRequiredDefaultDescription
inputanyYes-Dados de entrada para transformar (array ou objeto)
stepsarrayYes-Dados de entrada para transformar (array ou objeto)

Output:

FieldTypeDescription
resultanyArray de etapas de transformação a serem aplicadas em ordem
original_countintegerDados transformados
result_countintegerDados transformados
steps_appliedintegerContagem de itens após a transformação

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}]

Template de Texto

data.text.template

Preencher template de texto com variaveis

Parameters:

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

Output:

FieldTypeDescription
statusstringStatus da operacao
resultstringStatus da operacao

Example: Example

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

Gerar XML

data.xml.generate

Gerar string XML a partir de objeto ou array

Parameters:

NameTypeRequiredDefaultDescription
dataobjectYes-Dados para converter em XML
root_tagstringNorootNome da tag do elemento raiz
prettybooleanNoTrueFormatar a saída XML
encodingstringNoutf-8Codificação de caracteres para a saída XML
declarationbooleanNoTrueIncluir cabeçalho de declaração XML

Output:

FieldTypeDescription
xmlstringString XML gerada

Example: Example

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

Analisar XML

data.xml.parse

Analisar string XML em objeto

Parameters:

NameTypeRequiredDefaultDescription
contentstringNo-String XML para analisar
file_pathstringNo-Caminho para o arquivo XML a ser analisado
preserve_attributesbooleanNoTruePreservar atributos XML na saída analisada

Output:

FieldTypeDescription
resultobjectXML analisado como objeto
root_tagstringNome da tag do elemento raiz

Example: Example

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

Gerar YAML

data.yaml.generate

Gerar string YAML a partir de objeto ou array

Parameters:

NameTypeRequiredDefaultDescription
dataanyYes-Dados para converter em YAML
default_flow_stylebooleanNoFalseUsar estilo de fluxo para estruturas aninhadas
sort_keysbooleanNoFalseOrdenar chaves alfabeticamente
indentnumberNo2Número de espaços para indentação
allow_unicodebooleanNoTruePermitir caracteres unicode na saída

Output:

FieldTypeDescription
yamlstringString YAML gerada

Example: Example

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

Analisar YAML

data.yaml.parse

Analisar string YAML em objeto

Parameters:

NameTypeRequiredDefaultDescription
contentstringNo-String YAML para analisar
file_pathstringNo-Caminho para o arquivo YAML a ser analisado
multi_documentbooleanNoFalseAnalisar YAML com múltiplos documentos (separados por ---)

Output:

FieldTypeDescription
resultanyYAML analisado como objeto ou array
typestringTipo do resultado analisado

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

Chaves do Objeto

object.keys

Obter todas as chaves de um objeto

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary

Output:

FieldTypeDescription
keysarrayLista de chaves do objeto
countnumberLista de chaves do objeto

Example: Get object keys

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

Mesclar Objetos

object.merge

Mesclar multiplos objetos em um

Parameters:

NameTypeRequiredDefaultDescription
objectsarrayYes-Array of objects to process

Output:

FieldTypeDescription
resultobjectObjeto mesclado

Example: Merge user data

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

Omitir do Objeto

object.omit

Omitir chaves especificas de um objeto

Parameters:

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

Output:

FieldTypeDescription
resultobjectObjeto sem as chaves omitidas

Example: Omit sensitive fields

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

Selecionar do Objeto

object.pick

Selecionar chaves especificas de um objeto

Parameters:

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

Output:

FieldTypeDescription
resultobjectObjeto com apenas as chaves selecionadas

Example: Pick user fields

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

Valores do Objeto

object.values

Obter todos os valores de um objeto

Parameters:

NameTypeRequiredDefaultDescription
objectobjectYes-Input object/dictionary

Output:

FieldTypeDescription
valuesarrayLista de valores do objeto
countnumberLista de valores do objeto

Example: Get object values

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

Released under the Apache 2.0 License.