<div dir="ltr">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 <span style="font-family:'courier new',monospace">gunzip-through-ports</span><font face="arial, helvetica, sans-serif">, long enough to uncompress the entire file, then reads are pretty quick afterwords.</font><div>
<br></div><div>Here's what I have thus far:</div><div><br></div><div><div><font face="courier new, monospace">#lang racket</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">(require file/gunzip)</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">(define-values (pipe-from pipe-to) (make-pipe))</font></div><div><font face="courier new, monospace">(with-input-from-file "test.rkt.gz"</font></div>
<div><font face="courier new, monospace"> (lambda ()</font></div><div><font face="courier new, monospace"> (gunzip-through-ports (current-input-port) pipe-to)</font></div><div><font face="courier new, monospace"> (for ([line (in-lines pipe-from)])</font></div>
<div><font face="courier new, monospace"> (displayln line))))</font></div></div><div><br></div><div style>As an additional problem, that code doesn't actually work. <font face="courier new, monospace">in-lines</font> seems to be waiting for an <font face="courier new, monospace">eof-object?</font> that <font face="courier new, monospace">gunzip-through-ports</font> isn't sending. Am I missing something? It ends up just hanging after reading and printing the file.<br>
</div><div style><br></div><div style>Ultimately, a <font face="courier new, monospace">with-input-from-gzipped-file</font> 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.</div>
</div>