Sha256: b4dd3eb9a7b70bb6ba8ea64c6a2fd7647572b9c548507769c6532a0a8aa78c27
Contents?: true
Size: 631 Bytes
Versions: 3
Compression:
Stored size: 631 Bytes
Contents
require 'csv' module Muzzy class Util def self.fetch_header_and_first_row(filepath, col_sep) raise ArgumentError, "filepath required" if filepath.nil? raise ArgumentError, "not found file" unless File.exists?(filepath) header_row, first_row = nil, nil CSV.foreach(filepath, col_sep: col_sep).each_with_index do |row, i| if i == 0 header_row = row elsif i == 1 first_row = row else break end end return [header_row, first_row] rescue ArgumentError => e raise e rescue => e return [-1, -1] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
muzzy-0.1.13 | lib/muzzy/util.rb |
muzzy-0.1.12 | lib/muzzy/util.rb |
muzzy-0.1.11 | lib/muzzy/util.rb |