From f3d640912bb1a68dafbe2f891165a2141d0d6fc0 Mon Sep 17 00:00:00 2001 From: Joe Bloggs Date: Mon, 28 Oct 2013 13:13:40 +0000 Subject: [PATCH 1/2] Add support for CSV files CSV = Comma Separated Variables I just copied tabs but with ',' instead of '\t' Altered items: commas --- src/HSL/Stdlib.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/HSL/Stdlib.hs b/src/HSL/Stdlib.hs index 50f077d..f2116d5 100644 --- a/src/HSL/Stdlib.hs +++ b/src/HSL/Stdlib.hs @@ -1,5 +1,5 @@ -module HSL.Stdlib (groupOn, sortOn, sortOnR, hist, tabs, tally, logScale) where +module HSL.Stdlib (groupOn, sortOn, sortOnR, hist, tabs, commas, tally, logScale) where import Data.Ord (comparing) @@ -35,6 +35,8 @@ hist = tally . flip zip (repeat 1) tabs :: Datum a => a -> [T.Text] -> [a] tabs _ = map (parseMany . T.split (=='\t')) +commas :: Datum a => a -> [T.Text] -> [a] +commas _ = map (parseMany . T.split (=='\t')) logScale :: (Integral a) => a -> a logScale = (2^) . truncate . logBase 2 . fromIntegral From 04f69e50536c4b35edd16f6030671615af7543c4 Mon Sep 17 00:00:00 2001 From: Joe Bloggs Date: Mon, 28 Oct 2013 13:19:21 +0000 Subject: [PATCH 2/2] Bugfix: oops, forgot the comma Altered items: commas --- src/HSL/Stdlib.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HSL/Stdlib.hs b/src/HSL/Stdlib.hs index f2116d5..77f3708 100644 --- a/src/HSL/Stdlib.hs +++ b/src/HSL/Stdlib.hs @@ -36,7 +36,7 @@ tabs :: Datum a => a -> [T.Text] -> [a] tabs _ = map (parseMany . T.split (=='\t')) commas :: Datum a => a -> [T.Text] -> [a] -commas _ = map (parseMany . T.split (=='\t')) +commas _ = map (parseMany . T.split (==',')) logScale :: (Integral a) => a -> a logScale = (2^) . truncate . logBase 2 . fromIntegral