Permalink
Browse files

Add example for streaming decoding to examples/

  • Loading branch information...
1 parent 98dd114 commit 7e13f3777a20aa9513c205182236e5342419ce60 @tibbe committed Nov 17, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 examples/StreamingIndexBasedDecode.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
+import qualified Data.ByteString.Lazy as BL
+import Data.Csv.Streaming
+import Data.Foldable (for_)
+
+main :: IO ()
+main = do
+ csvData <- BL.readFile "salaries.csv"
+ -- N.B. The Foldable instance skips records that failed to
+ -- convert.
+ for_ (decode False csvData) $ \ (name, salary :: Int) ->
+ putStrLn $ name ++ " earns " ++ show salary ++ " dollars"

0 comments on commit 7e13f37

Please sign in to comment.