Reputation: 44061
The file is very large so I cannot store in memory. I iterate line by line as follows
for (line <- Source.fromFile(file).getLines) {
}
How can I specify that the first line should be skipped?
Upvotes: 15
Views: 9992
Reputation: 125217
How about:
for (line <- Source.fromFile(file).getLines.drop(1)) {
// ...
}
drop
will simply advance the iterator (returned by getLines
) past the specified number of elements.
Upvotes: 45