Read the first (or some number) of lines of file to treat special (e.g. the first line is column headings), then use eachLine to read in rest of file. Also illustrate simple use of GZIPInputStream. Other experiments had me convinced that eachLine always reset to beginning of stream, but apparently not.
- #!/usr/bin/env groovy
- import java.util.zip.*;
- fileName = args
- // Create a GZIPInputStream...
- // And a reader so we get the nice readLine...
- // Read the special first line...column headings say.
- firstLine = reader.readLine()
- println "firstLine: $firstLine"
- // Read the rest of the file...reader picks up where
- // it was left off with eachLine
- println "line: $line"
CommentsSubscribe to comments
You need to login to post a comment.