Thursday, September 17, 2009

Dumping Header From Scala Source Line Iterator

The Scala source trait is great for easily iterating threw the lines of a file.


Source.fromFile(pooledSHRNAFile).getLines.foreach(line => {
println(line)
})


Often though you need to get rid of the header. So do this.


var lines = Source.fromFile(pooledSHRNAFile).getLines
lines.next //Dump Header
lines.foreach(line => {
val tokes = line.split("\t").toList
val vitroCount = Integer.parseInt(0)
})