Hi Ruby friends,
I have lots of file loops w the ff form:
File.open("test") do |f|
f.each do |line|
p line
end
end
However, the file has headers that I want to skip. So I skip first few line
of headers like ...
scheme 1:
File.open("test") do |f|
f.each do |line|
if f.lineno <= 5 then next end
p line
end
end
or
scheme 2:
File.open("test") do |f|
f.readline <---- just read
f.readline
f.each do |line|
p line
end
end
and I combine scheme 1 & 2 like:
File.open("test") do |f|
while (f.lineno <= 4)
f.readline
end
f.each do |line|
p line
end
end
Is there any other way better than this?
I like something that when it opens, its already on the line that I want...
or maybe, I'm asking too much.. I'm just newbie, so pls bear w me..
Many thanks,
-botp