All pastes #245166 Raw Edit

Anonymous

public ruby v1 · immutable
#245166 ·published 2006-11-10 17:45 UTC
rendered paste body
#!/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