Module: FlatFile::TSV

Defined in:
lib/flat_file/tsv.rb

Class Method Summary collapse

Class Method Details

.from_file(filepath, delim: "\t") ⇒ Array<Hash{String => String}>

Read a TSV file and return its contents as an array of hashes.

Parameters:

  • filepath (String)

    Path to the TSV file.

  • delim (String) (defaults to: "\t")

Returns:

  • (Array<Hash{String => String}>)


11
12
13
14
15
16
17
18
# File 'lib/flat_file/tsv.rb', line 11

def self.from_file(filepath, delim: "\t")
  return ::CSV.read(
    filepath,
    col_sep: delim,
    headers: true,
    quote_char: "\x00",
  ).map(&:to_hash)
end