Parsing files .log

18 views
Skip to first unread message

dheyfesson pinheiro

unread,
Apr 6, 2015, 3:03:39 PM4/6/15
to rubyonra...@googlegroups.com
Good afternoon, I'm starting in ruby,
I am grieving for a parser to a file.

file_example File.open = "foo.txt", "r"
file_example.each do | line |
puts line
end

here I can print all lines of the file.

but as I can get only specific lines and use them in a function?

ok. I I separate them with regex. but not know how to use these lines that separated within a function.

Colin Law

unread,
Apr 6, 2015, 4:50:32 PM4/6/15
to rubyonra...@googlegroups.com
If I understand correctly perhaps you need something like

useful_lines = []
file_example File.open = "foo.txt", "r"
file_example.each do | line |
if some_test_to_indicate_whether_this_is_a_useful_line( line )
useful_lines << line
end
end

Colin
Reply all
Reply to author
Forward
0 new messages