class_docstr: Sample collection reader for reading a DeepSpeech CSV file
  Automatically orders samples by CSV column wav_filesize (if available).
class_docstr_tok: ["Sample","collection","reader","for","reading","a","DeepSpeech","CSV","file","Automatically","orders","samples","by","CSV","column","wav_filesize","(","if","available",")","."]
docstr: Parameters
  ----------
  csv_filename : str
      Path to the CSV file containing sample audio paths and transcripts
  labeled : bool or None
      If True: Reads LabeledSample instances. Fails, if CSV file has no transcript column.
      If False: Ignores transcripts (if available) and reads (unlabeled) util.audio.Sample instances.
      If None: Automatically determines if CSV file has a transcript column
      (reading util.sample_collections.LabeledSample instances) or not (reading util.audio.Sample instances).
  reverse : bool
      If the order of the samples should be reversed
code: def __init__(self, csv_filename, labeled=None, reverse=False):
      """
      Parameters
      ----------
      csv_filename : str
          Path to the CSV file containing sample audio paths and transcripts
      labeled : bool or None
          If True: Reads LabeledSample instances. Fails, if CSV file has no transcript column.
          If False: Ignores transcripts (if available) and reads (unlabeled) util.audio.Sample instances.
          If None: Automatically determines if CSV file has a transcript column
          (reading util.sample_collections.LabeledSample instances) or not (reading util.audio.Sample instances).
      reverse : bool
          If the order of the samples should be reversed
      """
      rows = []
      with open_remote(csv_filename, "r", encoding="utf8") as csv_file:
          reader = csv.DictReader(csv_file)
          if "transcript" in reader.fieldnames:
              if labeled is None:
                  labeled = True
          elif labeled:
              raise RuntimeError(
                  "No transcript data (missing CSV column)"
              )
          for row in reader:
              wav_filename = Path(row["wav_filename"])
              if not wav_filename.is_absolute() and not is_remote_path(
                  row["wav_filename"]
              ):
                  wav_filename = (
                      Path(csv_filename).parent / wav_filename
                  )
                  wav_filename = str(wav_filename)
              else:
                  # Pathlib otherwise removes a / from filenames like hdfs://
                  wav_filename = row["wav_filename"]
              wav_filesize = (
                  int(row["wav_filesize"])
                  if "wav_filesize" in row
                  else 0
              )
              if labeled:
                  rows.append(
                      (wav_filename, wav_filesize, row["transcript"])
                  )
              else:
                  rows.append((wav_filename, wav_filesize))
      super(CSV, self).__init__(rows, labeled=labeled, reverse=reverse)
  
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 CSV object from inherited base classes: SampleList with example: obj = CSV(csv_filename, labeled, reverse)