write

write(mappings: Iterable[MappingTypeVar], path: str | Path | TextIO, *, metadata: MappingSet | dict[str, Any] | MappingSetRecord | None = None, converter: Converter | None = None, exclude_mappings: Iterable[MappingTypeVar] | None = None, exclude_mappings_key: Callable[[MappingTypeVar], X] | None = None, drop_duplicates: bool = False, drop_duplicates_key: Callable[[MappingTypeVar], Y] | None = None, sort: bool = False, columns: Sequence[str] | None = None, exclude_columns: Collection[str] | None = None, exclude_prefixes: Collection[str] | None = None, condense: bool = True, reduce_prefix_map: bool = True) None[source]

Write semantic mappings as SSSOM TSV.

Parameters:
  • mappings – an iterable of semantic mappings

  • path – the path or file-like object to write to

  • metadata – metadata to write to the header of the SSSOM file

  • converter – the converter whose internal prefix map will be written in the header of the SSSOM file. If reduce_prefix_map is True, then only prefixes used in semantic mappings will be written

  • exclude_mappings – an iterable of semantic mappings to exclude. If used, streaming writing is not possible.

  • exclude_mappings_key – a key function for identifying “redundant” mappings

  • drop_duplicates – whether to drop redundant mappings. If used, streaming writing is not possible.

  • drop_duplicates_key – a key function for identifying “duplicate” mappings

  • sort – Should mappings be sorted? If used, streaming writing is not possible.

  • columns – If given, explicitly use these columns instead of inferring which have data in the given semantic mappings. This is required to enable streaming writing.

  • exclude_columns – columns to explicitly exclude from writing, whether columns is given or not

  • exclude_prefixes – prefixes to explicitly exclude from writing

  • condense – Should fields from mappings be condensed into the SSSOM header? Defaults to True, but must be turned off to enable streaming writing.

  • reduce_prefix_map – Should the prefix map be reduced based on prefixes appearing in mappings and the metadata? If used, streaming writing is not possible.