Skip to content

Extract

extract

extract_package(package, **kwargs)

Extract data from all resources in a datapackage based on their configured mode.

api

check_multipart_files(resource, **kwargs)

Download every file of an API resource.

The base URL in sources is combined with the file name of resource.path and of each one of resource.extrapaths.

extract_api(resource, **kwargs)

Request the resource source and save the response to resource.path.

email

email_connection(resource, **kwargs)

Connect to an e-mail server, search for the most recent e-mail matching the given criteria and save its attachments to the resource path.

extract_email(mailbox, resource, **kwargs)

Extract the most recent e-mail matching a subject and save its attachments to the given resource path.

command

check_cli_commands(resource, **kwargs)

Execute the command line commands defined for the resource.

run_cli_command(command, resource, **kwargs)

Execute a single command, logging the error without stopping the others.

sql

extract_sql(resource, **kwargs)

Run a query on a database and save the result to resource.path.

The connection is a SQLAlchemy URL read from the environment variable DATABASE_URL. The query is query, or SELECT * FROM <table> when table is given, or else the content of the file in query_file (relative to the descriptor, defaults to sql/<resource name>.sql).

write_file(table, path, config)

Save a PETL table to path. CSV files use encoding (defaults to utf-8) and delimiter (defaults to ,).