Generator of digested values from csv file in filepath

    Parameters
    ----------
    filepath:String
    \tFile path of csv file to read
    dialect: Object
    \tCsv dialect
    digest_types: tuple of types
    \tTypes of data for each col
331855
def csv_digest_gen(filepath, dialect, has_header, digest_types):
    

    with open(filepath, "rb") as csvfile:
        csvreader = csv.reader(csvfile, dialect=dialect)

        if has_header:
            # Ignore first line
            for line in csvreader:
                break

        for line in csvreader:
            yield digested_line(line, digest_types)
1287734
def open(self, filepath):
        
        with io.open(filepath, 'r', encoding='utf-8') as fp:
            content = fp.read()
        return content
1319306
def superReadCSV(filepath, first_codec='UTF_8', usecols=None,
                 low_memory=False, dtype=None, parse_dates=True,
                 sep=',', chunksize=None, verbose=False, **kwargs):

        

        if isinstance(filepath, pd.DataFrame):
            return filepath

        assert isinstance(first_codec, str), "first_codec must be a string"

        codecs = ['UTF_8', 'ISO-8859-1', 'ASCII', 'UTF_16', 'UTF_32']
        try:
            codecs.remove(first_codec)
        except ValueError as not_in_list:
            pass
        codecs.insert(0, first_codec)
        errors = []
        for c in codecs:
            try:

                return pd.read_csv(filepath,
                                   usecols=usecols,
                                   low_memory=low_memory,
                                   encoding=c,
                                   dtype=dtype,
                                   parse_dates=parse_dates,
                                   sep=sep,
                                   chunksize=chunksize,
                                   **kwargs)
            # Need to catch `UnicodeError` here, not just `UnicodeDecodeError`,
            # because pandas 0.23.1 raises it when decoding with UTF_16 and the
            # file is not in that format:
            except (UnicodeError, UnboundLocalError) as e:
                errors.append(e)
            except Exception as e:
                errors.append(e)
                if 'tokenizing' in str(e):
                    pass
                else:
                    raise
        if verbose:
            [print(e) for e in errors]

        raise UnicodeDecodeError("Tried {} codecs and failed on all: \n CODECS: {} \n FILENAME: {}".format(
                        len(codecs), codecs, os.path.basename(filepath)))
291405
def load_from_file(filepath):
        
        class_inst = None
        expected_class = "Py3status"
        module_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
        if file_ext.lower() == ".py":
            py_mod = imp.load_source(module_name, filepath)
            if hasattr(py_mod, expected_class):
                class_inst = py_mod.Py3status()
        return class_inst
576392
def get_tp_from_file(file_path):
    
    match = TP_FROM_FILE_REGEX.match(file_path)
    if not match:
        print("File path is not valid: " + file_path)
        sys.exit(1)
    return match.group(1)
415063
def _read_csv(filepath, kwargs):
    """"""
    if 'delimiter' not in kwargs:
        kwargs['delimiter'] = ','
    if 'quotechar' not in kwargs:
        kwargs['quotechar'] = '"'
    if 'skiprows' not in kwargs:
        kwargs['skiprows'] = []
    if isinstance(kwargs['skiprows'], int):
        kwargs['skiprows'] = [i for i in range(kwargs['skiprows'])]
    if 'format' in kwargs:
        format_ = kwargs['format']
        kwargs.pop('format', None)
    else:
        format_ = 'default'
    skiprows = kwargs['skiprows']
    kwargs.pop('skiprows', None)

    kwargs_open = {'newline': ''}
    mode = 'r'
    if sys.version_info < (3, 0):
        kwargs_open.pop('newline', None)
        mode = 'rb'
    with open(filepath, mode, **kwargs_open) as fp:
        if format_ == 'default':
            reader = csv.reader(fp, **kwargs)
            data = EList([row for row in reader])
            data = data.remove_indices(skiprows)
        elif format_ == 'dicts':
            reader_list = csv.DictReader(fp, **kwargs)
            data = [row for row in reader_list]
        else:
            raise NotImplementedError('Format \'{}\' unknown'
                                      .format(format_))
    return data
1355248
def from_csv(cls, path:PathOrStr, csv_name, valid_pct:float=0.2, test:Optional[str]=None,
                 tokenizer:Tokenizer=None, vocab:Vocab=None, classes:Collection[str]=None, delimiter:str=None, header='infer',
                 text_cols:IntsOrStrs=1, label_cols:IntsOrStrs=0, label_delim:str=None,
                 chunksize:int=10000, max_vocab:int=60000, min_freq:int=2, 
                 mark_fields:bool=False, include_bos:bool=True, include_eos:bool=False, **kwargs) -> DataBunch:
        ""
        df = pd.read_csv(Path(path)/csv_name, header=header, delimiter=delimiter)
        df = df.iloc[np.random.permutation(len(df))]
        cut = int(valid_pct * len(df)) + 1
        train_df, valid_df = df[cut:], df[:cut]
        test_df = None if test is None else pd.read_csv(Path(path)/test, header=header, delimiter=delimiter)
        return cls.from_df(path, train_df, valid_df, test_df, tokenizer=tokenizer, vocab=vocab, classes=classes, text_cols=text_cols,
                           label_cols=label_cols, label_delim=label_delim, chunksize=chunksize, max_vocab=max_vocab,
                           min_freq=min_freq, mark_fields=mark_fields, 
                           include_bos=include_bos, include_eos=include_eos, **kwargs)
307012
def parse_file_path(filepath):
    # type: (pathlib.Path) -> Tuple[str, str, str]
    
    if not isinstance(filepath, pathlib.Path):
        filepath = pathlib.Path(filepath)
    dirname = '/'.join(filepath.parts[:len(filepath.parts) - 1])
    if len(dirname) == 0:
        dirname = None
    if len(filepath.parts) > 0:
        fname = filepath.parts[-1]
    else:
        fname = None
    fname, snapshot = blobxfer.util.parse_fileshare_or_file_snapshot_parameter(
        fname)
    return (dirname, fname, snapshot)
1260458
def from_filepath(cls, filepath):
        ''''''
        assert(os.path.exists(filepath))
        return cls(read_file(filepath))
854979
def infer_delimiter(filepath):
    
    ext = os.path.splitext(filepath)[1][1:].lower()
    return {"txt": "\t", "tsv": "\t", "csv": ","}.get(ext)
320316
def get_file_extension(self, filepath):
        
        mtype = magic.from_file(filepath, mime=True)
        if type(mtype) == bytes:
            mtype = mtype.decode("utf-8")

        if mtype == "audio/mpeg":
            ext = ".mp3"
        elif mtype == "audio/x-wav":
            ext = ".wav"
        else:
            ext = "." + self.get("original-format")
        return ext
1293435
def _generate_examples(self, filepath):
    
    for idx, line in enumerate(tf.io.gfile.GFile(filepath, "rb")):
      if idx == 0:
        continue  # skip header
      line = tf.compat.as_text(line.strip())
      split_line = line.split("\t")
      # Examples not marked with a three out of five consensus are marked with
      # "-" and should not be used in standard evaluations.
      if split_line[0] == "-":
        continue
      # Works for both splits even though dev has some extra human labels.
      yield {
          "premise": split_line[5],
          "hypothesis": split_line[6],
          "label": split_line[0]
      }
1180936
def _gen_csv_data(self, f, dialect):
		
		reader = self._get_csv_reader(f, dialect)

		for line in reader:
			try:
				datum = line[self.ipa_col]
			except IndexError:
				mes = 'Could not find IPA data on line: {}'.format(line)
				raise ValueError(mes)

			yield datum, reader.line_num
66203
def load_csvf(fpath, fieldnames, encoding):
    
    with open(fpath, mode='r', encoding=encoding) as f:
        snippet = f.read(8192)
        f.seek(0)

        dialect = csv.Sniffer().sniff(snippet)
        dialect.skipinitialspace = True
        return list(csv.DictReader(f, fieldnames=fieldnames, dialect=dialect))
1229612
def ReadManyFromPath(filepath):
  
  with io.open(filepath, mode="r", encoding="utf-8") as filedesc:
    return ReadManyFromFile(filedesc)
1092776
def _read(filepath_or_buffer: FilePathOrBuffer, kwds):
    """"""
    encoding = kwds.get('encoding', None)
    if encoding is not None:
        encoding = re.sub('_', '-', encoding).lower()
        kwds['encoding'] = encoding

    compression = kwds.get('compression', 'infer')
    compression = _infer_compression(filepath_or_buffer, compression)

    # TODO: get_filepath_or_buffer could return
    # Union[FilePathOrBuffer, s3fs.S3File, gcsfs.GCSFile]
    # though mypy handling of conditional imports is difficult.
    # See https://github.com/python/mypy/issues/1297
    fp_or_buf, _, compression, should_close = get_filepath_or_buffer(
        filepath_or_buffer, encoding, compression)
    kwds['compression'] = compression

    if kwds.get('date_parser', None) is not None:
        if isinstance(kwds['parse_dates'], bool):
            kwds['parse_dates'] = True

    # Extract some of the arguments (pass chunksize on).
    iterator = kwds.get('iterator', False)
    chunksize = _validate_integer('chunksize', kwds.get('chunksize', None), 1)
    nrows = kwds.get('nrows', None)

    # Check for duplicates in names.
    _validate_names(kwds.get("names", None))

    # Create the parser.
    parser = TextFileReader(fp_or_buf, **kwds)

    if chunksize or iterator:
        return parser

    try:
        data = parser.read(nrows)
    finally:
        parser.close()

    if should_close:
        try:
            fp_or_buf.close()
        except ValueError:
            pass

    return data
98674
def read_data_file(path)
      case File.extname(path).downcase
      when ".csv"
        CSV.read(path,
                 :headers  => true,
                 :encoding => site.config["encoding"]).map(&:to_hash)
      when ".tsv"
        CSV.read(path,
                 :col_sep  => "\t",
                 :headers  => true,
                 :encoding => site.config["encoding"]).map(&:to_hash)
      else
        SafeYAML.load_file(path)
      end
    end