From: Qubert Date: 2003-06-17T11:20:00+09:00 Subject: Extracting columns from Array withSubstitution problem I have a little hurdle to jump on this code. I am manipulating a lot of data that is in a columnar format. The first row has the titles of each column that I successfully use to call the columns through the command line (ARGV.shift). Below I show 2 attempts to pull out the columns of data using the reference to the first row. The first one (y1) works, until I found that absent data was marked by one or more *. So y1 was changing *** to 0, but I need to input these missing data points as -9. So y2 was attempted, in which it finds the ** but then for some reason inputs the entire array x at the end of the newly collected array. Now I didn't believe that it would work, but I didn't expect it to input array x either. So I would like some help creating code that will collect a new array like y1 but substitute -9 for ***. Partial code: arg1 = ARGV.shift arg2 = ARGV.shift label = Array.new # for y1, y2 I found I didn't need to declare y1=Array.new? label = x.shift # first line is headers for the columns y1 = x.collect {|j| j[label.index(arg1)].to_i} # works but changes ** into 0 y2 = x.each do |j| # doesn't work, inputs all of x as y2, i.e. y2 = x � if /\*+/ =~ j[label.index(arg2)] ��� -9 else j[label.index(arg2)].to_i � end end Sample dataset: DIR SPD GUS CLG 030 6 *** 722 360 5 *** 722 020 * *** 722 030 6 *** 722 Thank you for the help, Ruby is great, I just haven't found the "Way". Qubert