Sha256: 27d94e750b3d9c19b11b4a81eccfeea04712175dff4a5257b4da5fd0f2d346f8

Contents?: true

Size: 453 Bytes

Versions: 3

Compression:

Stored size: 453 Bytes

Contents

require "csv"

module FlatFile
  module TSV

    # Read a TSV file and return its contents as an array of hashes.
    #
    # @param filepath [String] Path to the TSV file.
    # @param delim [String]
    # @return [Array<Hash{String => String}>]
    def self.from_file(filepath, delim: "\t")
      return ::CSV.read(
        filepath,
        col_sep: delim,
        headers: true,
        quote_char: "\x00",
      ).map(&:to_hash)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flat_file-0.3.0 lib/flat_file/tsv.rb
flat_file-0.2.0 lib/flat_file/tsv.rb
flat_file-0.1.0 lib/flat_file/tsv.rb