write

function of dascore.io.core source

write(
    patch_or_spool ,
    path: str | pathlib._local.Path | upath.core.UPath[str, Path, UPath] ,
    file_format: str ,
    file_version: str | None[str, None] = None,
    **kwargs ,
)-> ’_PathT’

Write a Patch or Spool to disk.

Parameters

Parameter Description
patch_or_spool The Patch or spool to write to disk.
path The path to the file.
file_format The string indicating the format to write.
file_version Optionally specify the version of the file, else use the latest
version for the format.
**kwargs Options the format’s writer names, such as encoding.

Raises

UnknownFiberFormatError - Could not determine the fiber format. ParameterError - The path is an examples:// name, which is read-only. - An option the format’s writer does not accept. CoordError - The format cannot store a coordinate’s holes, jitter or step.

Note

A patch reaches the format’s writer whole. Writers keep each coordinate’s step, holes and jitter, or refuse, saying to regularize (Patch.snap_coords, Patch.fill_gaps) or split (Patch.split_gaps) first.

Examples

from pathlib import Path
import dascore as dc

patch = dc.get_example_patch()
path = Path("output.h5")
_ = dc.write(patch, path, "dasdae")

assert path.exists()
path.unlink()