Validator Exporter
Warning
This section is a work in progress
CSVExporter
Bases: Exporter
CSVExporter is a subclass of Exporter that provides functionality to export data to a CSV file. Methods
init(): Initializes the CSVExporter by registering the "csv" export format and its handler. staticmethod _export(data, file): Exports the provided data to a CSV file. Parameters ---------- data : list or dict The data to be exported, typically a list of dictionaries or a dictionary. file : str or file-like object The file path or file-like object where the CSV will be written. Returns ------- str A message indicating the file has been exported.
Source code in datachecker/checks_loaders_and_exporters/validator_exporter.py
Exporter
Exporter class for registering and exporting data in various formats.
This class allows you to register exporter functions for different formats and use them
to export data.
Exporter functions should accept two arguments: data (the data to export) and file
(the file or file-like object to write to).
Attributes:
format_dictionary (dict): A class-level dictionary mapping format names to
exporter functions.
Methods:
init(self, format, exporter_function):
Registers a new exporter function for the specified format.
export(cls, data, format, file):
Exports the given data using the exporter function registered for the specified format.
Raises:
ValueError: If the specified format is not supported.
Source code in datachecker/checks_loaders_and_exporters/validator_exporter.py
JSONExporter
Bases: Exporter
JSONExporter is a subclass of Exporter that handles exporting validation logs to a JSON file. Methods
init(): Initializes the JSONExporter by registering the "json" export format and the associated export method. _export(data, file): Static method that writes the provided data to a file in JSON format. Parameters: data (Any): The validation log data to be exported. file (str): The path to the file where the data will be written. Returns: str: A message indicating the file has been exported.
Source code in datachecker/checks_loaders_and_exporters/validator_exporter.py
TXTExporter
Bases: Exporter
TXTExporter is a subclass of Exporter that handles exporting data to a plain text (.txt) file. Methods
init(): Initializes the TXTExporter by registering the "txt" format and its export method. staticmethod _export(data, file): Exports the provided data to a text file, writing each item on a new line. Parameters
data : iterable The data to be exported, where each item will be written as a separate line in the file. file : str or PathLike The path to the file where the data will be exported. Returns
str A message indicating the file has been exported.
Source code in datachecker/checks_loaders_and_exporters/validator_exporter.py
YAMLExporter
Bases: Exporter
YAMLExporter is a subclass of Exporter that handles exporting data to a YAML file. Methods
init(): Initializes the YAMLExporter by setting the export format to 'yaml' and assigning the export method. _export(data, file): Static method that writes the provided data to the specified file in YAML format. Parameters
data : Any The data to be exported to YAML. file : str The path to the file where the YAML data will be written. Returns
str A message indicating the file has been exported.