You'll need to avoid holding onto the head of your line-seq, which
means you'll need to make multiple passes over the data, one for the
as, one for the bs, and etc., with the output a lazy seq of lazy seqs.
> (defn data-lines
> "Returns data lines in file (i.e. all lines that do not start with
> '#')
> Returns: sequence containing data lines"
> [filename]
> (drop-while is-comment? (line-seq (reader filename))))
The description doesn't match the function, unless it's guaranteed
that no line will start with # after the first line that doesn't do
so. You may want remove instead of drop-while here, or to change the
doc string.
> Also, I'd prefer to read in gzip'd tab-delimited files instead of
> uncompressed tab-delimited files. What is the idiomatic clojure way
> to do this?
There are zip functions in the Java standard library. I don't know if
they can handle gzip, or just pkzip. In the worst case, you'd have no
library you could use. Even then, it could be done in at least two
ways.
1. Use Runtime/exec to call shell tools to gunzip the file to a
temporary file for processing.
2. Read at wikipedia and implement gunzip in Clojure, using byte arrays
and whatever other tools you'd need to work with binary data at a low
level, and/or Java's ByteBuffer and related classes.