As the title says, I'd like to be able to read lines from a file that is inside a zip archive, using zip-conduit (the zip files I'm dealing with are very big, so I need to be able to do this in constant memory). I grok the very basic idea of conduits, but have never used them in anger, and am feeling quite stuck as to where to start. I've read the conduits tutorial, but I'm having trouble matching that up with my problem.
The zip-conduit documentation says one can source from a zip archive via something like the following:
import qualified Data.Conduit.Binary as CB
import Codec.Archive.Zip
withArchive archivePath $ do
name:_ <- entryNames
sourceEntry name $ CB.sinkFile name
I presume what I need to do is write something in place of CB.sinkFile
. Data.Conduit.Text
has a lines
function — could this be used in some way to get the lines out of the file?
I would really appreciate a simple example, say using putStrLn
to write out the lines of a simple text file that is archived inside a zip file. Thanks in advance.