aboutsummaryrefslogtreecommitdiff
path: root/src/CSV.hs
diff options
context:
space:
mode:
authorJoris2019-03-10 19:15:45 +0100
committerJoris2019-03-10 19:15:45 +0100
commit8e03a571033a5d02d2287a2b1d1edd8b57aa2462 (patch)
tree03d6965bb65322dbac03edf2d6a30ee856c197f6 /src/CSV.hs
parentc41f16ed474376ad8a61a75d8b7f9ef543f359b4 (diff)
Scrap result page and make a CSV of it
Diffstat (limited to 'src/CSV.hs')
-rw-r--r--src/CSV.hs17
1 files changed, 17 insertions, 0 deletions
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