Anonymous
public ruby v1 · immutable#!/usr/bin/ruby -wrequire 'CSV'old_table = CSV.open('file.csv','r')index = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}] # create 10 index hashes, one for each columnold_table.each do |row| row.each_with_index do |column,col_num| (index[col_num][column] ||= []) << row end (index[col_num][row[3] + [row[4]] ||= []) << rowendprint index[0]['whatever'] # all the rows with 'whatever' as the first valueprint index[10]['Bobfruit']puts "Out of the block now"puts new_table