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 todetakon.detakon.Converterto be apathlib.Path.A additional
"type"setting can be provided in theSourcesection to modify the python type provided as an argument, when theargumentcan 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.DictReaderclass in thecsvmodule.Detakon uses
csv.DictReaderto read CSV source data. Any additional settings can be provided that matches the parameters thatcsv.DictReaderaccepts.For example, a
delimitersetting 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": ","
}