CSV#
This generator outputs the classes of the LinkML schema in CSV format. Each row contains the identifier, mappings and description of each class in the schema.
This generator does not output a CSV that is configured based on the template. If fillable template spreadsheets are required, consider using [gen-excel](https://linkml.io/linkml/generators/excel.html) or [DataHarmonizer](https://github.com/cidgoh/DataHarmonizer).
Auto-generated docs#
Code#
Generate CSVs
- class linkml.generators.csvgen.CsvGenerator(schema: str | ~typing.TextIO | ~linkml_runtime.linkml_model.meta.SchemaDefinition | ~linkml.utils.generator.Generator | ~pathlib.Path, schemaview: ~linkml_runtime.utils.schemaview.SchemaView | None = None, format: str | None = None, metadata: bool = True, useuris: bool | None = None, log_level: int | None = 30, mergeimports: bool | None = True, source_file_date: str | None = None, source_file_size: int | None = None, logger: ~logging.Logger | None = None, verbose: bool | None = None, output: str | None = None, namespaces: ~linkml_runtime.utils.namespaces.Namespaces | None = None, directory_output: bool = False, base_dir: str = None, metamodel_name_map: dict[str, str] = None, importmap: str | ~collections.abc.Mapping[str, str] | None = None, emit_prefixes: set[str] = <factory>, metamodel: ~linkml.utils.schemaloader.SchemaLoader = None, stacktrace: bool = False, include: str | ~pathlib.Path | ~linkml_runtime.linkml_model.meta.SchemaDefinition | None = None, sep: str | None = None, closure: set[linkml_runtime.linkml_model.meta.ClassDefinitionName] | None = None, writer: ~csv.DictWriter | None = None, _str_io: ~_io.StringIO | None = None)[source]#
Generates CSV summaries
Note: this generator is not widely used, and has largely been supplanted by schemasheets
- closure: set[linkml_runtime.linkml_model.meta.ClassDefinitionName] | None = None#
List of classes to include in output
- end_schema(**kwargs) str [source]#
Visited once at the end of generation
@param kwargs: Arguments passed through from CLI – implementation dependent
- generatorname: ClassVar[str] = 'csvgen.py'#
Name of the generator. Override with os.path.basename(__file__)
- generatorversion: ClassVar[str] = '0.1.1'#
Version of the generator. Consider deprecating and instead use overall linkml version
- uses_schemaloader: ClassVar[bool] = True#
Old-style generator that uses the SchemaLoader and visitor pattern
- visit_class(cls: ClassDefinition) bool [source]#
Visited once per schema class
@param cls: class being visited @return: Visit slots and end class. False means skip and go on
- visit_schema(classes: list[linkml_runtime.linkml_model.meta.ClassDefinitionName] = None, **_) None [source]#
Visited once at the beginning of generation
@param kwargs: Arguments passed through from CLI – implementation dependent
- writer: DictWriter | None = None#
Python dictwriter
Command Line#
Note: The output from this command needs to be piped in order to create a CSV file.
gen-csv#
Generate CSV/TSV file from LinkML model
gen-csv [OPTIONS] YAMLFILE
Options
- -V, --version#
Show the version and exit.
- -r, --root <root>#
Class(es) to transform
- -f, --format <format>#
Output format
- Default:
'csv'
- Options:
csv | tsv
- --metadata, --no-metadata#
Include metadata in output
- Default:
True
- --useuris, --metauris#
Use class and slot URIs over model uris
- Default:
True
- -im, --importmap <importmap>#
Import mapping file
- --log_level <log_level>#
Logging level
- Default:
'WARNING'
- Options:
CRITICAL | ERROR | WARNING | INFO | DEBUG
- -v, --verbose#
Verbosity. Takes precedence over –log_level.
- --mergeimports, --no-mergeimports#
Merge imports into source file (default=mergeimports)
- --stacktrace, --no-stacktrace#
Print a stack trace when an error occurs
- Default:
False
Arguments
- YAMLFILE#
Required argument