Re: storing and manipulating columns of data
- From: Tim Hunter <TimHunter@xxxxxxxxx>
- Date: Sat, 30 Jun 2007 20:59:57 +0900
baptiste Auguié wrote:
Hi,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.
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.
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]
.
- References:
- storing and manipulating columns of data
- From: baptiste Auguié
- storing and manipulating columns of data
- Prev by Date: Re: question: referencing a variable with a variable
- Next by Date: Re: storing and manipulating columns of data
- Previous by thread: Re: storing and manipulating columns of data
- Next by thread: Re: storing and manipulating columns of data
- Index(es):
Relevant Pages
|