*** layout: overview slug: nemo-curator/nemo\_curator/utils/writer\_utils title: nemo\_curator.utils.writer\_utils ---------------------------------------- ## Module Contents ### Classes | Name | Description | | ------------------------------------------------------------------------- | ---------------------------------------------------------------------- | | [`JsonEncoderCustom`](#nemo_curator-utils-writer_utils-JsonEncoderCustom) | Custom JSON encoder that handles types that are not JSON serializable. | ### Functions | Name | Description | | ----------------------------------------------------------------- | ---------------------------- | | [`write_bytes`](#nemo_curator-utils-writer_utils-write_bytes) | Write bytes to local path. | | [`write_csv`](#nemo_curator-utils-writer_utils-write_csv) | Write csv to local path. | | [`write_json`](#nemo_curator-utils-writer_utils-write_json) | Write json to local path. | | [`write_parquet`](#nemo_curator-utils-writer_utils-write_parquet) | Write parquet to local path. | ### API ```python class nemo_curator.utils.writer_utils.JsonEncoderCustom() ``` **Bases:** `JSONEncoder` Custom JSON encoder that handles types that are not JSON serializable. Example: ```python json.dumps(data, cls=JsonEncoderClass) ``` ```python nemo_curator.utils.writer_utils.JsonEncoderCustom.default( obj: object ) -> str | object ``` Encode an object for JSON serialization. **Parameters:** Object to encode. **Returns:** `str | object` Encoded object. ```python nemo_curator.utils.writer_utils.write_bytes( buffer: bytes, dest: pathlib.Path, desc: str, source_video: str, verbose: bool, backup_and_overwrite: bool = False, overwrite: bool = False ) -> None ``` Write bytes to local path. **Parameters:** Bytes to write. Destination to write. Description of the write. Source video. Verbosity. Storage client. Backup and overwrite. Overwrite. ```python nemo_curator.utils.writer_utils.write_csv( dest: pathlib.Path, desc: str, source_video: str, data: list[list[str]], verbose: bool, backup_and_overwrite: bool = False ) -> None ``` Write csv to local path. **Parameters:** Destination to write. Description of the write. Source video. Data to write. Verbosity. Storage client. Backup and overwrite. ```python nemo_curator.utils.writer_utils.write_json( data: dict[str, typing.Any], dest: pathlib.Path, desc: str, source_video: str, verbose: bool, backup_and_overwrite: bool = False, overwrite: bool = False ) -> None ``` Write json to local path. **Parameters:** Data to write. Destination to write. Description of the write. Source video. Verbosity. Storage client. Backup and overwrite. Overwrite. ```python nemo_curator.utils.writer_utils.write_parquet( data: list[dict[str, str]], dest: pathlib.Path, desc: str, source_video: str, verbose: bool, backup_and_overwrite: bool = False, overwrite: bool = False ) -> None ``` Write parquet to local path. **Parameters:** Data to write. Destination to write. Description of the write. Source video. Verbosity. Storage client. Whether to backup existing file before overwriting. Whether to overwrite existing file.