4 views
Skip to first unread message

prasoona alluri

unread,
Jan 5, 2009, 11:38:39 PM1/5/09
to watir-...@googlegroups.com
How to convert log file into html using watir

Tiffany Fodor

unread,
Jan 6, 2009, 4:31:29 PM1/6/09
to Watir General
Hi!

This is really more of a Ruby question than a Watir question, but I'll
give it a shot. :) I'm sure a Ruby guru could give you a better
answer.

You'll need to do some more digging for html specifics, but here's a
start:

resultsFile = "c:\\test\\reports\\OriginalFile.txt"

if File.exist?("c:\\test\\reports\\OriginalFile.txt")
#modify each line of your log file and save it to a variable
sContent
sContent = File.readlines(resultsFile, '\n')
sContent.each do |line|
#I use line.sub! here to substitute the text I want, but you
may need to use other string
#methods to add html tags to your text and more logic to add
the correct tags in the correct places
end

#create a new file, dump the contents of sContent to it and close
it
newFile = File.new("c:\\test\\reports\\NewFile.html", "w+")
newFile.puts sContent
newFile.close
end

I hope this helps!

-Tiffany

Alister Scott

unread,
Jan 6, 2009, 7:20:16 PM1/6/09
to Watir General
Please ensure you have a meaningful subject for posts to this mailing
list.
Reply all
Reply to author
Forward
0 new messages