Commit 706df18e authored by Mike Ledger's avatar Mike Ledger

quote all

parent 3a8179c1
......@@ -17,7 +17,9 @@ import Control.Monad.Trans.State.Strict (State, get, modify',
import Data.ByteString (ByteString)
import qualified Data.ByteString.Streaming as B
import qualified Data.ByteString.Streaming.Char8 as Q (lines)
import Data.Csv (HasHeader (..))
import Data.Csv (EncodeOptions (..),
HasHeader (..), Quoting (..),
defaultEncodeOptions)
import Data.List (isSuffixOf)
import qualified Data.Map.Strict as Map
import Data.Typeable
......@@ -306,6 +308,11 @@ combine opts ms =
Just OpDifference -> foldr1 Map.difference ms
_union -> Map.unions ms)
encodeOpts :: EncodeOptions
encodeOpts = defaultEncodeOptions
{ encQuoting = QuoteAll
}
main :: IO ()
main = do
opts@Options{..} <- getRecord "Map-like operations on csv files"
......@@ -321,7 +328,7 @@ main = do
(unHelpful infiles) >>= \o ->
-- write output
let (labelled, r) = combine opts o
writeCsv opts' = output opts' . Csv.encode . mapM_ (S.yield . uncurry (:)) . Map.toList
writeCsv opts' = output opts' . Csv.encodeWith encodeOpts . mapM_ (S.yield . uncurry (:)) . Map.toList
in do
writeCsv opts r
when (saveLabels == Just True) $ iforM_ labelled $ \name -> writeCsv opts
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment