#!/usr/bin/ruby -w require 'CSV' old_table = CSV.open('file.csv','r') index = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}] # create 10 index hashes, one for each column old_table.each do |row| row.each_with_index do |column,col_num| (index[col_num][column] ||= []) << row end end print index[0]['whatever'] # all the rows with 'whatever' as the first value puts "Out of the block now" puts new_table