Created
July 11, 2018 05:14
-
-
Save HirotoShioi/78858e99c30ecf3a7f059f508cfacbcb to your computer and use it in GitHub Desktop.
Example of an decompressing and analyzing the zip file using zip libray (http://hackage.haskell.org/package/zip)
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
module Main where | |
import Codec.Archive.Zip | |
import Control.Monad (forM_) | |
import qualified Data.ByteString as BS | |
import qualified Data.Map.Strict as M | |
import Data.Text (Text) | |
import Data.Text.Encoding (decodeUtf8With) | |
import Data.Text.Encoding.Error (ignore) | |
import qualified Data.Text.IO as T | |
import System.Environment (getArgs) | |
zipFilePath :: FilePath | |
zipFilePath = "./zips/Windows-Logs.zip" | |
data Knowledge = Knowledge String String Int | |
deriving Show | |
type Analysis = M.Map Knowledge String | |
extractIssuesFromLogs :: [BS.ByteString] -> Analysis -> Either Text Analysis | |
extractIssuesFromLogs = undefined | |
analysis :: Analysis | |
analysis = undefined | |
main :: IO () | |
main = do | |
rawLogs<- withArchive zipFilePath $ do | |
entries <- M.keys <$> getEntries | |
mapM getEntry (take 5 entries) | |
let eitherResult = extractIssuesFromLogs rawLogs analysis | |
case eitherResult of | |
Left err -> print err | |
Right result -> print result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment