class_docstr: Defines a Dataset of columns stored in CSV, TSV, or JSON format.
docstr: Create a TabularDataset given a path, file format, and field list.
  
  Args:
      path (str): Path to the data file.
      format (str): The format of the data file. One of "CSV", "TSV", or
          "JSON" (case-insensitive).
      fields ((list(tuple(str, Field)) or dict[str: tuple(str, Field)): If using a list,
          the format must be CSV or TSV, and the values of the list
          should be tuples of (name, field).
          The fields should be in the same order as the columns in the CSV or TSV
          file, while tuples of (name, None) represent columns that will be ignored.
  
          If using a dict, the keys should be a subset of the JSON keys or CSV/TSV
          columns, and the values should be tuples of (name, field).
          Keys not present in the input dictionary are ignored.
          This allows the user to rename columns from their JSON/CSV/TSV key names
          and also enables selecting a subset of columns to load.
      skip_header (bool): Whether to skip the first line of the input file.
      csv_reader_params(dict): Parameters to pass to the csv reader.
          Only relevant when format is csv or tsv.
          See
          https://docs.python.org/3/library/csv.html#csv.reader
          for more details.
      kwargs (dict): passed to the Dataset parent class.
docstr_tok: ["Create","a","TabularDataset","given","a","path",",","file","format",",","and","field","list",".","Args",":","path","(","str",")",":","Path","to","the","data","file",".","format","(","str",")",":","The","format","of","the","data","file",".","One","of","``","CSV","''",",","``","TSV","''",",","or","``","JSON","''","(","case-insensitive",")",".","fields","(","(","list","(","tuple","(","str",",","Field",")",")","or","dict","[","str",":","tuple","(","str",",","Field",")",")",":","If","using","a","list",",","the","format","must","be","CSV","or","TSV",",","and","the","values","of","the","list","should","be","tuples","of","(","name",",","field",")",".","The","fields","should","be","in","the","same","order","as","the","columns","in","the","CSV","or","TSV","file",",","while","tuples","of","(","name",",","None",")","represent","columns","that","will","be","ignored",".","If","using","a","dict",",","the","keys","should","be","a","subset","of","the","JSON","keys","or","CSV\/TSV","columns",",","and","the","values","should","be","tuples","of","(","name",",","field",")",".","Keys","not","present","in","the","input","dictionary","are","ignored",".","This","allows","the","user","to","rename","columns","from","their","JSON\/CSV\/TSV","key","names","and","also","enables","selecting","a","subset","of","columns","to","load",".","skip_header","(","bool",")",":","Whether","to","skip","the","first","line","of","the","input","file",".","csv_reader_params","(","dict",")",":","Parameters","to","pass","to","the","csv","reader",".","Only","relevant","when","format","is","csv","or","tsv",".","See","https",":","\/\/docs.python.org\/3\/library\/csv.html","#","csv.reader","for","more","details",".","kwargs","(","dict",")",":","passed","to","the","Dataset","parent","class","."]
code: def __init__(
      self,
      path,
      format,
      fields,
      skip_header=False,
      csv_reader_params=None,
      **kwargs,
  ):
      """Create a TabularDataset given a path, file format, and field list.
  
      Args:
          path (str): Path to the data file.
          format (str): The format of the data file. One of "CSV", "TSV", or
              "JSON" (case-insensitive).
          fields ((list(tuple(str, Field)) or dict[str: tuple(str, Field)): If using a list,
              the format must be CSV or TSV, and the values of the list
              should be tuples of (name, field).
              The fields should be in the same order as the columns in the CSV or TSV
              file, while tuples of (name, None) represent columns that will be ignored.
  
              If using a dict, the keys should be a subset of the JSON keys or CSV/TSV
              columns, and the values should be tuples of (name, field).
              Keys not present in the input dictionary are ignored.
              This allows the user to rename columns from their JSON/CSV/TSV key names
              and also enables selecting a subset of columns to load.
          skip_header (bool): Whether to skip the first line of the input file.
          csv_reader_params(dict): Parameters to pass to the csv reader.
              Only relevant when format is csv or tsv.
              See
              https://docs.python.org/3/library/csv.html#csv.reader
              for more details.
          kwargs (dict): passed to the Dataset parent class.
      """
      if csv_reader_params is None:
          csv_reader_params = {}
      format = format.lower()
      make_example = {
          "json": Example.fromJSON,
          "dict": Example.fromdict,
          "tsv": Example.fromCSV,
          "csv": Example.fromCSV,
      }[format]
  
      with io.open(os.path.expanduser(path), encoding="utf8") as f:
          if format == "csv":
              reader = csv.reader(f, **csv_reader_params)
          elif format == "tsv":
              reader = csv.reader(
                  f, delimiter="\t", **csv_reader_params
              )
          else:
              reader = f
  
          if format in ["csv", "tsv"] and isinstance(fields, dict):
              if skip_header:
                  raise ValueError(
                      "When using a dict to specify fields with a {} file,"
                      "skip_header must be False and"
                      "the file must have a header.".format(format)
                  )
              header = next(reader)
              field_to_index = {
                  f: header.index(f) for f in fields.keys()
              }
              make_example = partial(
                  make_example, field_to_index=field_to_index
              )
  
          if skip_header:
              next(reader)
  
          examples = [make_example(line, fields) for line in reader]
  
      if isinstance(fields, dict):
          fields, field_dict = [], fields
          for field in field_dict.values():
              if isinstance(field, list):
                  fields.extend(field)
              else:
                  fields.append(field)
  
      super(TabularDataset, self).__init__(examples, fields, **kwargs)
  
imports: import csv
  import gzip
  import io
  import os
  import shutil
  import tarfile
  import zipfile
  from functools import partial
  import torch.utils.data
  from torchtext.data.utils import RandomShuffler
  from torchtext.utils import download_from_url
  from .example import Example
label_desc: Use image node_id 1 to create a new TabularDataset object from inherited base classes: Dataset with example: obj = TabularDataset(path, format, fields, skip_header, csv_reader_params)