class CsvTool

Constants

VERSION

Public Class Methods

convert_to_hash_array(csv_array) click to toggle source
# File lib/csv_tool.rb, line 4
def self.convert_to_hash_array(csv_array)
  fields = csv_array.shift
  csv_array.collect { |record| Hash[*fields.zip(record).flatten ] }
end
remove_column(csv_hash_array, column_name) click to toggle source
# File lib/csv_tool.rb, line 9
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
remove_row_with_value(csv_hash_array, column_name, value) click to toggle source
# File lib/csv_tool.rb, line 17
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