Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Others have recommended good books, but here's a glimpse just immediately.

    import Control.Monad (forM_)
    import Data.List.Split (splitOn)
    import Data.List (transpose)
    import System.IO

    main :: IO ()
    main = do
      withFile "file.file" ReadMode $ \handle ->
        contents <- hGetContents handle
        let clines = lines contents
            ccols  = transpose (map (splitOn ",") lines)
        forM_ (ccols !! 3) $ \cell -> do
          putStrLn cell
Then take a look at the following packages

    http://hackage.haskell.org/package/split
    http://hackage.haskell.org/package/mysql-simple
    http://hackage.haskell.org/package/sqlite-simple


I think this is the corrected version

    import Control.Monad (forM_)
    import Data.List.Split (splitOn)
    import Data.List (transpose)
    import System.IO

    main :: IO ()
    main = do
      withFile "tel.csv" ReadMode $ \handle -> do 
           contents <- hGetContents handle
           let clines = lines contents
               ccols  = transpose (map (splitOn ",") clines)
           forM_ (ccols !! 3) $ \cell -> do
             putStrLn cell


Good catch—obviously I wrote that freehand :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: