From: "baptiste AuguiƩ" Date: 2007-06-29T20:48:41+09:00 Subject: newbie questions on processing numerical data from text files --Apple-Mail-4-799574399 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi, Hope you can help me get started with these trivial questions. I've got a practical problem, and the Ruby cookbook to help me, but a few combinations of the two haven't produced any interesting results yet. I'd need a simple useful example to start with and then make my own variations. Here is my practical problem: - I open a text file, locate a line according to some keyword or line number, and change a value - I run a fortran program - I read a text file (output of this program), extract several numerical values and export them in a two column text file The way I've done that so far is using bash commands such as 'awk', 'grep', ... but i need some loops and it's getting too big for a sensible bash script. Could you help me get started in Ruby with the simpler example below? Here is the content of "sampleTextFile.dat": > this is a meaningless line > another one > > maybe this line acts as a keyword for the following data > > 1 3.1 (415, 19e-12) > 2 6 (3, 13e-14) > 1 3.1 (415, 19e-12) > 2 6 (3, 13e-14) > > other useless words ... I would like to read this data in some sort of array/hash, and export the first column and the product of the last two columns to a new file "results.dat". This should be enough to understand the spirit I guess, with the probably trivial problem to call the external program. Any advice welcome. Many thanks in advance! baptiste --Apple-Mail-4-799574399--