Transform¶
transform
¶
transform_package(package, **kwargs)
¶
Transform and export all resources in a datapackage.
datapackage
¶
get_output_settings(resource)
¶
Extract output settings from the resource custom metadata.
write_files(package, resource, table, path, format, extension, encoding, delimiter, **kwargs)
¶
Export a PETL table to the configured output format.
update_metadata(resource, path, format, compression, extension, encoding, delimiter, cli, **kwargs)
¶
Update resource metadata after transformation to match the generated output file.
build_datapackage(package)
¶
Build and save the updated datapackage descriptor as JSON.
replace
¶
apply_replace(field, table)
¶
Replace parts of the values of fields that declare a replace property.
Each key is a regex replaced by its value, in order.
Values that are not strings, such as missing values, are kept.
compute
¶
apply_compute(schema, field, table)
¶
Add columns computed by Python expressions to fields that declare a compute property.
Each expression is evaluated per row, with the row's values by field name.
The columns are added to the schema as strings, right after the field.
anonymize
¶
command
¶
flatten_custom(block)
¶
Merge a custom block into one dict. Accepts a mapping or a list of one-key maps; anything else is empty.
build_child_env(resource)
¶
Copy os.environ and JSON-encode each flattened custom key as an env var. Returns nothing when custom is missing or empty, so the child inherits the parent environment unchanged.
build_stdin_data(table, stdin, encoding, delimiter, **kwargs)
¶
Serialize a PETL table to CSV bytes, to pipe into CLI commands via stdin. Returns nothing when stdin mode is off or there is no table to serialize.
check_cli_commands(resource, table, stdin, encoding, delimiter, **kwargs)
¶
Execute the command line commands defined for the resource, piping the transformed table into each one's stdin when configured.
run_cli_command(command, resource, data, **kwargs)
¶
Execute a single command, logging the error without stopping the others.