aboutsummaryrefslogtreecommitdiff
path: root/src/CSV.hs
blob: 9ad2974c106584baa77a4cec5c52017d9b31bfb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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