Class: Eco::CSV

Inherits:
CSV show all
Extended by:
Data::Files
Defined in:
lib/eco/csv.rb,
lib/eco/csv/table.rb

Defined Under Namespace

Classes: Table

Constant Summary

Constants included from Data::Files

Data::Files::DEFAULT_TIMESTAMP_PATTERN

Constants included from Data::Files::Encoding

Data::Files::Encoding::BOM_BYTES

Instance Attribute Summary

Attributes included from Language::AuxiliarLogger

#logger

Class Method Summary collapse

Methods included from Data::Files::ClassMethods

#copy_file, #create_directory, #csv_files, #dir_exists?, #file_basename, #file_empty?, #file_exists?, #file_fullpath, #file_name, #file_path, #folder_files, #script_subfolder, #split, #timestamp, #timestamp_file

Methods included from Data::Files::Encoding

#encoding, #file_empty?, #file_exists?, #get_file_content_with_encoding, #has_bom?, #remove_bom, #scoped_encoding

Methods included from Language::AuxiliarLogger

#log

Methods included from Data::Files::InstanceMethods

#get_file_content, #read_with_tolerance

Class Method Details

.parse(data, **kargs, &block) ⇒ Eco::CSV::Table

Returns:



8
9
10
11
# File 'lib/eco/csv.rb', line 8

def parse(data, **kargs, &block)
  kargs = {headers: true, skip_blanks: true}.merge(kargs)
  Eco::CSV::Table.new(super(data, **kargs, &block))
end

.read(file, **kargs) ⇒ Eco::CSV::Table

Returns:



14
15
16
17
18
19
# File 'lib/eco/csv.rb', line 14

def read(file, **kargs)
  params = {}.tap do |prms|
    prms.merge!(encoding: kargs.delete(:encoding)) if kargs.key?(:encoding)
  end
  parse(get_file_content(file, **params), **kargs)
end