From: Nuralanur@... Date: 2006-03-16T17:27:13+09:00 Subject: Re: add to words syntaxes -------------------------------1142497609 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit ------------------------------------------------------------------------------ --------------- datafile="kest_kft.txt" # insert correct name here text=IO.readlines(datafile) # read lines into Array output_file="my_nicely_arranged_text_file.txt" # insert correct name here class String def do_first_script # insert tags here return result end def do_second_script #insert tags here return result end end f=File.new(output_file,"w") # first alternative # assuming that you'll always have the same one/two-column # structure text.each_with_index{|x,i| if i<5 f.puts x.do_first_script else f.puts x.do_second_script end } # second alternative (recommended) # use regexps - # assuming that you separate columns by tabs - and use tabs # for nothing else than separating columns text.each{|x| if x=~/\t/ f.puts x.do_first_script else f.puts x.do_second_script end } f.close ----------------------------------------------- Best regards, Axel -------------------------------1142497609--