Last active
May 27, 2019 16:34
-
-
Save simg/035ec4d08b866d59196bcc793c13d85e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Codec.Archive.Zip (sourceEntry, EntrySelector, getEntrySource, getEntry, getEntryName, getEntries, withArchive) | |
import Control.Monad.IO.Class (MonadIO, liftIO) | |
import Data.ByteString (ByteString) | |
--import Data.Foldable (for) | |
import Conduit (mapC, mapM_C, yieldMany, ($$)) | |
import Data.Conduit (Conduit(..), yield, runConduit, (.|), awaitForever) | |
import Data.Conduit.Binary as CB | |
import qualified Data.Conduit.List as CL | |
import qualified Data.Csv as Csv | |
import Lib.ParseCSV (parseCSV, parseCSVLine, CSV) | |
--import Data.Csv hiding (Csv) | |
--import Data.Csv.Conduit | |
import Data.Map (keys, Map) | |
import Data.String.Conversions (cs) | |
import Data.Text (Text) | |
import Path (parseAbsFile) | |
--import System.Directory (parseAbsFile) | |
import System.FilePath.Posix (takeExtension) | |
import System.TimeIt | |
parseCSVFromZip :: FilePath -> IO () | |
parseCSVFromZip fp = do | |
withArchive fp $ do | |
name:_ <- keys <$> getEntries | |
source <- getEntrySource name | |
runConduit $ source | |
.| CB.lines | |
.| mapC (csvToThing) | |
.| mapM_C print | |
fails with: Main.hs:27:5: error: | |
• Couldn't match type ‘IO’ with ‘Codec.Archive.Zip.ZipArchive’ | |
Expected type: Codec.Archive.Zip.ZipArchive () | |
Actual type: IO () | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The zip library seems to be missing a function to give you a sink in this way. It might be a good idea to submit a feature request to the library, it doesn't hurt to ask. Much like there are already
sourcEntry
andgetEntrySource
, maybe there should be agetEntrySink
to complementsinkEntry
.