From: Ben Martinek Date: 2009-08-09T12:40:59+09:00 Subject: Re: Basic iteration through text Ben Martinek wrote: > Howdy! > > So I am trying to parse a bit of an ugly text file to a new file, and > hence read each line of the old file, check the line for some conditions > and then execute some other stuff, and then write out some results to a > new file. Here is what I came up with: > > my_file = File.new("New_file.txt", "w+") > > File.foreach("LOG02.txt") do |line| > if line =~/^\$GPRMC/. > my_file.puts line > else > print "I did not read this line: #{line}" > end > end > > I have a feeling that I am missing something stupid but not quite sure > what it is. > > Good karma for a solution :-) Okay solved my problem, it was something stupid, like the period I didn't see after my line match statement. Nothing to see here people, move along.... -- Posted via http://www.ruby-forum.com/.