From 724dfe03451ac02aaf5aee223ae77b681f224b09 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 21 Apr 2022 22:27:03 -0400 Subject: [PATCH] implemented slurpRawLabelledCSV --- src/Data/CSV/Sip.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Data/CSV/Sip.hs b/src/Data/CSV/Sip.hs index f91156b..7a0895b 100644 --- a/src/Data/CSV/Sip.hs +++ b/src/Data/CSV/Sip.hs @@ -30,6 +30,7 @@ module Data.CSV.Sip ( slurpCSV, slurpRawCSV, slurpLabelledCSV, + slurpRawLabelledCSV, -- * Conduits labelFields, decodeRows, @@ -84,6 +85,15 @@ slurpLabelledCSV slurpLabelledCSV file = runConduit $ sourceFile file .| decodeRows .| labelFields .|consume +-- | read an entire CSV file with a header +slurpRawLabelledCSV + :: MonadResource m + => FilePath + -- ^ the path to the file to read + -> m [M.Map BS.ByteString BS.ByteString] +slurpRawLabelledCSV file = runConduit $ + sourceFile file .| decodeRawRows .| labelFields .|consume + -- | read a CSV stream, using the first row as a header containing -- field labels labelFields :: (Monad m, Ord a) => ConduitT [a] (M.Map a a) m ()