class_docstr: Sample collection writer for writing a CSV data-set and all its referenced WAV samples
class_docstr_tok: ["Sample","collection","writer","for","writing","a","CSV","data-set","and","all","its","referenced","WAV","samples"]
docstr: Parameters
  ----------
  csv_filename : str
      Path to the CSV file to write.
      Will create a directory (CSV-filename without extension) next to it and fail if it already exists.
  absolute_paths : bool
      If paths in CSV file should be absolute instead of relative to the CSV file's parent directory.
  labeled : bool or None
      If True: Writes labeled samples (util.sample_collections.LabeledSample) only.
      If False: Ignores transcripts (if available) and writes (unlabeled) util.audio.Sample instances.
  
  Currently only works with local files (not gs:// or hdfs://...)
code: def __init__(self, csv_filename, absolute_paths=False, labeled=True):
      """
      Parameters
      ----------
      csv_filename : str
          Path to the CSV file to write.
          Will create a directory (CSV-filename without extension) next to it and fail if it already exists.
      absolute_paths : bool
          If paths in CSV file should be absolute instead of relative to the CSV file's parent directory.
      labeled : bool or None
          If True: Writes labeled samples (util.sample_collections.LabeledSample) only.
          If False: Ignores transcripts (if available) and writes (unlabeled) util.audio.Sample instances.
  
      Currently only works with local files (not gs:// or hdfs://...)
      """
      self.csv_filename = Path(csv_filename)
      self.csv_base_dir = self.csv_filename.parent.resolve().absolute()
      self.set_name = self.csv_filename.stem
      self.csv_dir = self.csv_base_dir / self.set_name
      if self.csv_dir.exists():
          raise RuntimeError(
              '"{}" already existing'.format(self.csv_dir)
          )
      os.mkdir(str(self.csv_dir))
      self.absolute_paths = absolute_paths
      fieldnames = ["wav_filename", "wav_filesize"]
      self.labeled = labeled
      if labeled:
          fieldnames.append("transcript")
      self.csv_file = open_remote(
          csv_filename, "w", encoding="utf-8", newline=""
      )
      self.csv_writer = csv.DictWriter(
          self.csv_file, fieldnames=fieldnames
      )
      self.csv_writer.writeheader()
      self.counter = 0
  
imports: import os
  import io
  import csv
  import json
  import tarfile
  from pathlib import Path
  from functools import partial
  from .helpers import KILOBYTE, MEGABYTE, GIGABYTE, Interleaved, LenMap
  from .audio import Sample, AUDIO_TYPE_PCM, AUDIO_TYPE_OPUS, SERIALIZABLE_AUDIO_TYPES, get_loadable_audio_type_from_extension, write_wav
  from .io import open_remote, is_remote_path
label_desc: Use image node_id 1 to create a new CSVWriter object  with example: obj = CSVWriter(csv_filename, absolute_paths, labeled)