[racket] Cleaner way to work with gzipped data?
Is there a nice / idiomatic way to work with gzipped data in a streaming
manner (to avoid loading the rather large files into memory at once). So
far as I can tell, my code isn't doing that. It hangs for a while on the
call to gunzip-through-ports, long enough to uncompress the entire file,
then reads are pretty quick afterwords.
Here's what I have thus far:
#lang racket
(require file/gunzip)
(define-values (pipe-from pipe-to) (make-pipe))
(with-input-from-file "test.rkt.gz"
(lambda ()
(gunzip-through-ports (current-input-port) pipe-to)
(for ([line (in-lines pipe-from)])
(displayln line))))
As an additional problem, that code doesn't actually work. in-lines seems
to be waiting for an eof-object? that gunzip-through-ports isn't sending.
Am I missing something? It ends up just hanging after reading and printing
the file.
Ultimately, a with-input-from-gzipped-file would be nice (especially with
an output partner). I could easily write a function to do that though just
so long as I can get second problem working.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130805/76ca6ffd/attachment.html>