Source Section

The Source section is a dictionary of configuration settings to read the data source.

The argument setting is required. argument describes the type of value the source argument passed to detakon.detakon.Converter is.

Based on the context of the argument supplied, a type setting may also be required to further describe the type of the source argument supplied.

Fox example, the filepath value for an argument can accept a value of "str" if a string representation of a path is supplied, or a "path" if source is a pathlib.Path.

A format setting is also required to specify the structure or data type of the data contained in source.

Source Settings

Settings to control reading of the data source. argument and format settings are required.

Detakon uses pathlib.Path.open() to open files. Any additional settings can be provided that matches the parameters that pathlib.Path.open() accepts (except for mode). For example, an encoding setting can be supplied to change the character encoding.

argument

The arguments setting describes what type of argument was passed to the detakon.detakon.Converter as a source parameter.

This setting is required.

filepath

Supplying the "filepath" value to the argument setting describes the source as being a file path. It expects the source argument provided to detakon.detakon.Converter to be a pathlib.Path.

A additional "type" setting can be provided in the Source section to modify the python type provided as an argument, when the argument can accept other types of values.

Other accepted "type" values for "filepath":

  • "str" - to be used if the filepath supplied is a string.

format

The format setting should specify the stucture or data type contained in the source to detakon.detakon.Converter.

This setting is required.

csv

To be used for data structured as Comma Separated Values (CSV), or similar data that can be read by Python’s csv.DictReader class in the csv module.

Detakon uses csv.DictReader to read CSV source data. Any additional settings can be provided that matches the parameters that csv.DictReader accepts.

For example, a delimiter setting can be supplied to change the delimiter used in the data, such as to read Tab Separated Value (TSV) data.

See the Python Docs for DictReader for more details.

Examples

"Source": {
    "argument": "filepath",
    "type": "str",
    "encoding": "utf-8",
    "format": "csv",
    "delimiter": ","
}