Method: BioDSL::CSV.read_hash

Defined in:
lib/BioDSL/csv.rb

.read_hash(file, options = {}) ⇒ Object

Method that reads all CSV data from a file into an array of hashes (array of rows) which is returned. In the default mode all columns are read. Using the select option subselects the columns based on a given Array or if a heder line is present a given Hash. Visa versa for the reject option. Header lines are prefixed with ‘#’.

Options:

* delimiter.
* select.
* reject.


98
99
100
101
102
103
104
105
106
# File 'lib/BioDSL/csv.rb', line 98

def self.read_hash(file, options = {})
  data = []

  open(file) do |ios|
    ios.each_hash(options) { |row| data << row }
  end

  data
end