Skip to content

file_writer

Classes:

Name Description
FileWriter

Base class for file-based DataWriters.

Classes#

FileWriter #

Bases: DataWriter, ABC

Base class for file-based DataWriters.

Methods:

Name Description
no_leading_dot
write

Attributes:

Name Type Description
file_extension str

The file extension that the FileHandler should be used for, e.g., ".nc", ".csv", ...

Attributes#

file_extension instance-attribute #
file_extension: str

The file extension that the FileHandler should be used for, e.g., ".nc", ".csv", ...

Functions#

no_leading_dot #
no_leading_dot(v: str) -> str
Source code in tsdat/io/base/file_writer.py
@validator("file_extension")
def no_leading_dot(cls, v: str) -> str:
    return v.lstrip(".")
write abstractmethod #
write(
    dataset: xr.Dataset,
    filepath: Optional[Path] = None,
    **kwargs: Any
) -> None

Writes the dataset to the provided filepath.

This method is typically called by the tsdat storage API, which will be responsible for providing the filepath, including the file extension.

Parameters:

Name Type Description Default
dataset Dataset

The dataset to save.

required
filepath Optional[Path]

The path to the file to save.

None

Source code in tsdat/io/base/file_writer.py
@abstractmethod
def write(
    self, dataset: xr.Dataset, filepath: Optional[Path] = None, **kwargs: Any
) -> None:
    """-----------------------------------------------------------------------------
    Writes the dataset to the provided filepath.

    This method is typically called by the tsdat storage API, which will be
    responsible for providing the filepath, including the file extension.

    Args:
        dataset (xr.Dataset): The dataset to save.
        filepath (Optional[Path]): The path to the file to save.

    -----------------------------------------------------------------------------"""
    ...