File: StreamingIndexBasedDecode.hs

package info (click to toggle)
haskell-cassava 0.5.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 276 kB
  • sloc: haskell: 2,544; makefile: 3
file content (13 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
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 NoHeader csvData) $ \ (name, salary :: Int) ->
        putStrLn $ name ++ " earns " ++ show salary ++ " dollars"