Sha256: 7aefcaf41281112251574237a5f7c62d8175d3f77df8006f40ae10ca08f94b1d
Contents?: true
Size: 583 Bytes
Versions: 1
Compression:
Stored size: 583 Bytes
Contents
require "csv" class CsvTool def self.convert_to_hash_array(csv_array) fields = csv_array.shift csv_array.collect { |record| Hash[*fields.zip(record).flatten ] } end def self.remove_column(csv_hash_array, column_name) csv_hash_array.each do |row| if row.has_key?(column_name) row.delete(column_name) end end end def self.remove_row_with_value(csv_hash_array, column_name, value) csv_hash_array.each do |row| if row[column_name] == value csv_hash_array.delete_at(csv_hash_array.index(row)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv_tool-0.0.2 | lib/csv_tool.rb |