From 8e03a571033a5d02d2287a2b1d1edd8b57aa2462 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 10 Mar 2019 19:15:45 +0100 Subject: Scrap result page and make a CSV of it --- src/CSV.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/CSV.hs (limited to 'src/CSV.hs') diff --git a/src/CSV.hs b/src/CSV.hs new file mode 100644 index 0000000..9ad2974 --- /dev/null +++ b/src/CSV.hs @@ -0,0 +1,17 @@ +module CSV (lines, line) where + +import Data.Text (Text) +import qualified Data.Text as T +import Prelude hiding (lines) + +lines :: [[Text]] -> Text +lines = T.unlines . map line + +line :: [Text] -> Text +line = T.intercalate "," . map value + +value :: Text -> Text +value text = + if (T.isInfixOf "," text) + then T.concat [ "\"", text, "\"" ] + else text -- cgit v1.2.3