From: James Gray Date: 2008-10-03T00:16:47+09:00 Subject: Re: Parsing non-delimited text file On Oct 2, 2008, at 7:40 AM, Panu Kinnari wrote: > First file is read into array and array fed to method that does the > work. I'm not sure how big the actual data is, but if it's very large you may want to consider not using readlines(). You "slurp" all of this data into memory, but then walk through it one line at a time. Instead, you could just read it a line at a time, using foreach() instead of readlines(). > I have managed to extract customer id and I think other heading info > won't differ much from that, but now I got stuck when I tried to > determine if string starts with number to see if that row includes > product info. I tried start_with?(/\d+/)[0] but that didn't work. To check if a String begins with a number you can use: if str =~ /\A\d/ # handle string that starts with a number here end Hope that helps. James Edward Gray II