Friday, May 19, 2006

Read each line of a file conditionally in Boo

Just for the record, either C# or VB.NET can convert to Boo, but Boo does not convert to either.


namespace ParseLogsBoo

import System
import System.Collections
import System.Xml from System.Xml
import System.IO
import System.Reflection

testfile = "c:\\logs\\shortlog.txt"
if File.Exists(testfile):
print "Found shortlog.txt"




using input = StreamReader(testfile): //or you can use File.OpenText
for line in input:
line = line.Trim()
if line =~ "Starting processing|Finished processing":
print line

0 Comments:

Post a Comment

<< Home