From: Tim Hunter Date: 2007-06-30T20:59:57+09:00 Subject: Re: storing and manipulating columns of data baptiste Augui� wrote: > Hi, > > Being used to deal with Octave / Matlab, I'm a bit confused by Ruby > structures (arrays, hashes, etc). I have this data file "data.dat" > with 3 columns: > > I would like to think of the columns as arrays "a", "b", "c", execute > a loop along their indices, pick the values i want, and do something > with them. What would be a sensible data structure for this? > I can read this datafile line by line using IO:readlines("data.dat"), > but I cannot find a way to refer to one column in the array of strings > generated. > You can use String#split to split each line into an array of 3 numbers. If you want to use the array values as numbers, you'll need to use String#to_f as well to convert the strings to numeric values. ri String#split ri String#to_f -- RMagick OS X Installer [http://rubyforge.org/projects/rmagick/] RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?forum_id=1618] RMagick Installation FAQ [http://rmagick.rubyforge.org/install-faq.html]